1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
6 * Moonlight List (moonlight-list@lists.ximian.com)
8 * Copyright 2008 Novell, Inc. (http://www.novell.com)
10 * See the LICENSE file included with the distribution for details.
18 #include "deployment.h"
26 SetObjectType (Type::STYLE
);
37 GetSetters ()->Seal ();
42 // SetterBaseCollection
45 SetterBaseCollection::SetterBaseCollection ()
47 SetObjectType (Type::SETTERBASE_COLLECTION
);
51 SetterBaseCollection::Seal ()
54 CollectionIterator
*iter
= GetIterator ();
58 Types
*types
= Deployment::GetCurrent ()->GetTypes ();
60 while (iter
->Next () && (current
= iter
->GetCurrent (&error
))) {
61 SetterBase
*setter
= current
->AsSetterBase (types
);
69 SetterBaseCollection::AddedToCollection (Value
*value
, MoonError
*error
)
71 if (!value
|| !ValidateSetter (value
, error
))
74 SetterBase
*setter
= value
->AsSetterBase ();
75 setter
->SetAttached (true);
78 return DependencyObjectCollection::AddedToCollection (value
, error
);
82 SetterBaseCollection::RemovedFromCollection (Value
*value
)
84 value
->AsSetterBase ()->SetAttached (false);
85 DependencyObjectCollection::RemovedFromCollection (value
);
89 SetterBaseCollection::ValidateSetter (Value
*value
, MoonError
*error
)
91 Types
*types
= Deployment::GetCurrent ()->GetTypes ();
93 if (types
->IsSubclassOf (value
->GetKind (), Type::SETTER
)) {
94 Setter
*s
= value
->AsSetter (types
);
95 if (!s
->GetValue (Setter::PropertyProperty
)) {
96 MoonError::FillIn (error
, MoonError::EXCEPTION
, "Cannot have a null target property");
101 if (types
->IsSubclassOf (value
->GetKind (), Type::SETTERBASE
)) {
102 SetterBase
*s
= value
->AsSetterBase (types
);
103 if (s
->GetAttached ()) {
104 MoonError::FillIn (error
, MoonError::INVALID_OPERATION
, "Setter is currently attached to another style");
109 if (GetIsSealed ()) {
110 MoonError::FillIn (error
, MoonError::EXCEPTION
, "Cannot add a setter to a sealed style");
122 SetterBase::SetterBase ()
124 SetObjectType (Type::SETTERBASE
);
137 SetterBase::GetAttached ()
143 SetterBase::SetAttached (bool value
)
155 SetObjectType (Type::SETTER
);