Пример #1
0
        /// <summary>
        /// Generates an attribute from its XML representation.
        /// </summary>
        /// <param name="reader"></param>
        private static void AddDeserializedAttribute(DDAttributesCollection ac, XmlReader reader)
        {
            var name = reader.GetAttribute(DDSchema.XML_SERIALIZE_ATTRIBUTE_NAME);
            var t    = reader.GetAttribute(DDSchema.XML_SERIALIZE_ATTRIBUTE_TYPE);

            //if (name != null)
            //{
            DDValue v = null;

            //if (t != null) v = DDValueSxe.Deserialize(reader);
            v = DDValueSxe.Deserialize(reader);
            if (name != null)
            {
                ac.Add(name, v);
            }
            else
            {
                ac.Add(v);
            }

            //}

            //else
            //{
            //    if (reader.NodeType == XmlNodeType.Element) reader.ReadStartElement();
            //    if (reader.NodeType == XmlNodeType.EndElement) reader.ReadEndElement(); // need to close the opened element
            //}
        }
Пример #2
0
 /// <summary>
 /// Serializes the specified DDAttributesCollection into its XML representation and writes to a XML writer.
 /// The parent node must exist, for example, use IXmlSerializable interface
 /// </summary>
 /// <param name="n">the attributes collection to serialize</param>
 /// <param name="writer">XML writer used to write the XML document.</param>
 internal static void XMLSerialize(DDAttributesCollection ac, XmlWriter writer)
 {
     if (ac == null)
     {
         return;             // if attributes is null
     }
     foreach (var a in ac)
     {
         writer.WriteStartElement(DDSchema.XML_SERIALIZE_NODE_ATTRIBUTE);
         writer.WriteAttributeString(DDSchema.XML_SERIALIZE_ATTRIBUTE_NAME, a.Key);
         //if (a.Value != null) DDValueSxe.XMLSerialize(a.Value, writer);
         DDValueSxe.XMLSerialize(a.Value, writer);
         writer.WriteEndElement();
     }
 }
Пример #3
0
 /// <summary>
 /// Generates an object from its XML representation.
 /// </summary>
 /// <param name="reader"></param>
 public virtual void ReadXml(XmlReader reader)
 {
     this.v = DDValueSxe.Deserialize(reader);
 }
Пример #4
0
 /// <summary>
 /// Converts an object into its XML representation.
 /// </summary>
 /// <param name="writer"></param>
 public virtual void WriteXml(XmlWriter writer)
 {
     DDValueSxe.XMLSerialize(v, writer);
 }