void SetterBaseCollection::Seal () { SetIsSealed (true); CollectionIterator *iter = GetIterator (); MoonError err; Value *current; Types *types = Deployment::GetCurrent ()->GetTypes (); while (iter->Next (&err) && (current = iter->GetCurrent (&err))) { SetterBase *setter = current->AsSetterBase (types); setter->Seal (); } delete iter; }
bool ResourceDictionary::AddWithError (const char* key, Value *value, MoonError *error) { if (!key) { MoonError::FillIn (error, MoonError::ARGUMENT_NULL, "key was null"); return false; } Value *v = NULL; gpointer orig_key; gboolean exists = g_hash_table_lookup_extended (hash, key, &orig_key, (gpointer*)&v); if (exists) { MoonError::FillIn (error, MoonError::ARGUMENT, "An item with the same key has already been added"); return false; } v = new Value (*value); from_resource_dictionary_api = true; bool result = Collection::AddWithError (v, error) != -1; from_resource_dictionary_api = false; if (result) { g_hash_table_insert (hash, g_strdup (key), v); v->Weaken (GetDeployment ()); EmitChanged (CollectionChangedActionAdd, v, NULL, key); if (!strncmp (key, INTERNAL_TYPE_KEY_MAGIC_COOKIE, sizeof (INTERNAL_TYPE_KEY_MAGIC_COOKIE) - 1) && v->Is (GetDeployment (), Type::STYLE)) { DependencyObject *p = GetParent(); if (!p) return result; Style *style = v->AsStyle(); if (p->Is (Type::APPLICATION)) { // we modified the application's resources, so we need to traverse all layers CollectionIterator *iterator = p->GetDeployment()->GetSurface()->GetLayers()->GetIterator(); while (iterator->Next (NULL)) { Value *v = iterator->GetCurrent(NULL); FrameworkElement *fwe = v->AsFrameworkElement(); fwe->StyleResourceChanged (key, style); } delete iterator; } else if (p->Is (Type::FRAMEWORKELEMENT)) { // just traverse down from this frameworkelement ((FrameworkElement*)p)->StyleResourceChanged (key, style); } } } else { delete v; } return result; }