コード例 #1
0
ファイル: XmlList.cs プロジェクト: OOP-03376400/DF_GCS_W
        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();
            }
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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();
        }
コード例 #4
0
        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);
        }
コード例 #5
0
ファイル: XmlList.cs プロジェクト: OOP-03376400/DF_GCS_W
        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);
            }
        }
コード例 #6
0
        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();
        }
コード例 #7
0
        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();
        }
コード例 #8
0
        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();
            }
        }
コード例 #9
0
 public static T DeserializeObjectFromFile(string file_path)
 {
     return((T)XMLSerializeManager.DeserializeObjectFromFile(file_path, typeof(T)));
 }
コード例 #10
0
 public static T DeserializeObject(string xmlStr)
 {
     return((T)XMLSerializeManager.DeserializeObject(xmlStr, typeof(T)));
 }
コード例 #11
0
 public static T DeserializeObject(MemoryStream stream)
 {
     return((T)XMLSerializeManager.DeserializeObject(stream, typeof(T)));
 }
コード例 #12
0
 public static void SerializeObjectToFile(T obj, string file_path)
 {
     XMLSerializeManager.SerializeObjectToFile(obj, typeof(T), file_path);
 }
コード例 #13
0
 public static void SerializeObjectToFile(T obj, string file_path, bool useSafeOverwrite)
 {
     XMLSerializeManager.SerializeObjectToFile(obj, typeof(T), file_path, useSafeOverwrite);
 }
コード例 #14
0
 public static MemoryStream SerializeObjectToMemoryStream(T obj)
 {
     return(XMLSerializeManager.SerializeObjectToMemoryStream(obj, typeof(T)));
 }
コード例 #15
0
 public static string SerializeObject(T obj)
 {
     return(XMLSerializeManager.SerializeObject(obj, typeof(T)));
 }
コード例 #16
0
 public static XmlSerializer GetSerializer(Type t)
 {
     return(XMLSerializeManager.GetSerializer(t));
 }