/// <summary> /// Add an Xml ChildNode to the collection being deserialized /// </summary> /// <param name="_collection">The collection that's being deserialized</param> /// <param name="_xmlElement">The XmlElement containing the data for this element</param> /// <param name="_expectedTypes">The expected Type(s) for this element</param> /// <param name="_deserializer">The deserialization framework controlling this process</param> protected override void AddElementFromXml(object _collection, XmlElement _xmlElement, Type[] _expectedTypes, CDeserializer _deserializer) { var keyElem = _xmlElement[KEY_ELEMENT_NAME]; if (keyElem == null) { throw new XDeserializationError("Could not find the KEY element for the Dictionary<,> entry."); } var valueElem = _xmlElement[VALUE_ELEMENT_NAME]; if (valueElem == null) { throw new XDeserializationError("Could not find the VALUE element for the Dictionary<,> entry."); } var key = _deserializer.FrameworkDeserialize(keyElem, _expectedTypes[0]); var value = _deserializer.FrameworkDeserialize(valueElem, _expectedTypes[1]); var collection = (IDictionary)_collection; collection.Add(key, value); }
/// <summary> /// Add a single XmlElement to a collection, where that XmlElement is a child of the parent Collection element. /// </summary> /// <param name="_collection"></param> /// <param name="_xmlData"></param> /// <param name="_expectedTypes"></param> /// <param name="_deserializer"></param> protected override void AddElementFromXml(object _collection, XmlElement _xmlData, Type[] _expectedTypes, CDeserializer _deserializer) { var o = _deserializer.FrameworkDeserialize(_xmlData, _expectedTypes[0]); var collection = (IList)_collection; collection.Add(o); }
/// <summary> /// Add a single XmlElement to a collection, where that XmlElement is a child of the /// parent Collection element. /// </summary> /// <param name="_collection"></param> /// <param name="_xmlData"></param> /// <param name="_expectedTypes"></param> /// <param name="_deserializer"></param> protected override void AddElementFromXml(object _collection, XmlElement _xmlData, Type[] _expectedTypes, CDeserializer _deserializer) { var o = _deserializer.FrameworkDeserialize(_xmlData, _expectedTypes[0]); var ct = _collection.GetType(); var mi = ct.GetMethod("Add", _expectedTypes); mi.Invoke(_collection, new object[] { o }); }
/// <summary> /// Enumerate through the child nodes of the collection and deserialize each one. Use the /// method provided to add each element to the collection. /// </summary> /// <param name="_object">The working object to receive the data about the Stack</param> /// <param name="_parentNode">The node containing the elements of the Stack</param> /// <param name="_deserializer">The Deserializer controlling this deserializtion</param> /// <returns>TRUE always</returns> protected bool BasicDeserialize(CWorkingObject _object, XmlElement _parentNode, CDeserializer _deserializer) { if (!ATreatAsInterface.TreatAsInterface(_deserializer)) { return(false); } var theCollection = _object.GetExistingOrCreateNew <TCollectionType>(); foreach (XmlElement element in GetXmlChildren(_parentNode)) { var theElement = (TElementType)_deserializer.FrameworkDeserialize(element, typeof(TElementType)); AddElement(theCollection, theElement); } return(true); }