private void AddChildObject(XamlObjectElement obj) { object value = obj.Object; MutableObject mutable = value as MutableObject; if (mutable != null) { value = mutable.Object; } IList list = Object as IList; if (list != null) { list.Add(value); return; } IDictionary dict = Object as IDictionary; if (dict != null) { dict.Add(obj.GetDictionaryKey(), value); return; } XamlReflectionPropertySetter content_property = FindContentProperty(); if (content_property == null) { throw Parser.ParseException("Unable to add element {0} to element {1}.", obj.Name, Name); } content_property.SetValue(value); }
private void AddToDictionary(XamlObjectElement obj, object value) { IDictionary rd = accessors.Getter(target) as IDictionary; if (rd == null) { throw Parser.ParseException("Collection property in non collection type."); } string key = obj.GetDictionaryKey(); if (key == null) { throw Parser.ParseException("You must specify an x:Key or x:Name for elements in a ResourceDictionary"); } rd.Add(key, value); }
private void AddToDictionary (XamlObjectElement obj, object value) { IDictionary rd = accessors.Getter (target) as IDictionary; if (rd == null) throw Parser.ParseException ("Collection property in non collection type."); string key = obj.GetDictionaryKey (); if (key == null) throw Parser.ParseException ("You must specify an x:Key or x:Name for elements in a ResourceDictionary"); rd.Add (key, value); }
private void AddChildObject (XamlObjectElement obj) { IList list = Object as IList; if (list != null) { list.Add (obj.Object); return; } IDictionary dict = Object as IDictionary; if (dict != null) { dict.Add (obj.GetDictionaryKey (), obj.Object); return; } XamlReflectionPropertySetter content_property = FindContentProperty (); if (content_property == null) throw Parser.ParseException ("Unable to add element {0} to element {1}.", obj.Name, Name); content_property.SetValue (obj.Object); }