public void ReadXml(System.Xml.XmlReader r) { int depth = r.Depth; r.ReadStartElement(); bool hasRead = false; while (r.Depth > depth) { if (r.IsStartElement()) { XmlSerializer ser = XmlTypeAssociator <T> .GetSerializer(r); XMLSerializeManager.Report("Deserializing: " + r.Name); Add((T)ser.Deserialize(r)); r.MoveToContent(); } else { r.Read(); } hasRead = true; } if (hasRead) { r.ReadEndElement(); } }
public void ReadXml(XmlReader r) { r.ReadStartElement(); Id = r.GetAttribute("id"); r.ReadStartElement("items"); if (r.NodeType == System.Xml.XmlNodeType.EndElement) { r.ReadEndElement();//--items return; } while (r.NodeType != System.Xml.XmlNodeType.EndElement) { XMLSerializeManager.Report("Deserializing: " + r.Name); XmlSerializer valueSer = XmlTypeAssociator <T> .GetSerializer(r); object obj = valueSer.Deserialize(r); T value = (T)obj; if (value.Id != null) { this[value.Id] = value; } } r.ReadEndElement();//--items r.ReadEndElement(); }
public void WriteXml(System.Xml.XmlWriter w) { w.WriteStartElement("dictionary"); foreach (TKey key in Keys) { w.WriteStartElement("item"); w.WriteStartElement("key"); XmlSerializer keySer = XmlTypeAssociator <TKey> .GetSerializer(key.GetType()); XMLSerializeManager.Report("Serializing key: " + key.GetType().Name); keySer.Serialize(w, key); w.WriteEndElement(); w.WriteStartElement("value"); TValue value = this[key]; XmlSerializer valueSer = XmlTypeAssociator <TValue> .GetSerializer(value.GetType()); XMLSerializeManager.Report("Serializing value: " + value.GetType().Name); valueSer.Serialize(w, value); w.WriteEndElement(); w.WriteEndElement(); } w.WriteEndElement(); }
public void WriteXml(System.Xml.XmlWriter w) { if (m_Value == null) { return; } XmlSerializer ser = XmlTypeAssociator <T> .GetSerializer(m_Value.GetType()); XMLSerializeManager.Report("Serializing value: " + m_Value.GetType().Name); ser.Serialize(w, m_Value); }
public void WriteXml(System.Xml.XmlWriter w) { foreach (T item in this) { XmlSerializer ser = XmlTypeAssociator <T> .GetSerializer(item.GetType()); XMLSerializeManager.Report("Serializing item: " + item.GetType().Name); XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add("", ""); ser.Serialize(w, item, ns); } }
public void ReadXml(System.Xml.XmlReader r) { if (r.IsEmptyElement) { return; } r.ReadStartElement(); XmlSerializer ser = XmlTypeAssociator <T> .GetSerializer(r.Name); XMLSerializeManager.Report("Deserializing: " + r.Name); m_Value = (T)ser.Deserialize(r); r.MoveToContent(); r.ReadEndElement(); }
public void WriteXml(XmlWriter w) { if (Id != null) { w.WriteAttributeString("id", Id); } w.WriteStartElement("items"); foreach (IIdItem value in Values) { XMLSerializeManager.Report("Serializing: " + value.GetType().Name); XmlSerializer valueSer = XmlTypeAssociator <T> .GetSerializer(value.GetType()); valueSer.Serialize(w, value, new XmlSerializerNamespaces()); } w.WriteEndElement(); }
public void ReadXml(System.Xml.XmlReader r) { r.ReadStartElement(); bool hasRead = false; r.ReadStartElement("dictionary"); int begin_d = r.Depth; while (readStartElementOK("item", r)) { r.ReadStartElement("key"); XmlSerializer keySer = XmlTypeAssociator <TKey> .GetSerializer(r); XMLSerializeManager.Report("Deserializing Key: " + r.Name); TKey key = (TKey)keySer.Deserialize(r); readUntilEndElement("key", r); r.ReadStartElement("value"); XmlSerializer valueSer = XmlTypeAssociator <TValue> .GetSerializer(r); XMLSerializeManager.Report("Deserializing Value: " + r.Name); TValue value = (TValue)valueSer.Deserialize(r); readUntilEndElement("value", r); Add(key, value); r.ReadEndElement();//--item r.MoveToContent(); hasRead = true; } r.ReadEndElement();//--dictionary if (hasRead) { r.ReadEndElement(); } }
public static T DeserializeObjectFromFile(string file_path) { return((T)XMLSerializeManager.DeserializeObjectFromFile(file_path, typeof(T))); }
public static T DeserializeObject(string xmlStr) { return((T)XMLSerializeManager.DeserializeObject(xmlStr, typeof(T))); }
public static T DeserializeObject(MemoryStream stream) { return((T)XMLSerializeManager.DeserializeObject(stream, typeof(T))); }
public static void SerializeObjectToFile(T obj, string file_path) { XMLSerializeManager.SerializeObjectToFile(obj, typeof(T), file_path); }
public static void SerializeObjectToFile(T obj, string file_path, bool useSafeOverwrite) { XMLSerializeManager.SerializeObjectToFile(obj, typeof(T), file_path, useSafeOverwrite); }
public static MemoryStream SerializeObjectToMemoryStream(T obj) { return(XMLSerializeManager.SerializeObjectToMemoryStream(obj, typeof(T))); }
public static string SerializeObject(T obj) { return(XMLSerializeManager.SerializeObject(obj, typeof(T))); }
public static XmlSerializer GetSerializer(Type t) { return(XMLSerializeManager.GetSerializer(t)); }