Пример #1
0
        /// <summary>
        /// Converts an object into its XML representation.
        /// The parent node must exist, for example, use IXmlSerializable interface
        /// </summary>
        /// <param name="n">the node to serialize</param>
        /// <param name="writer">XML writer used to write the XML document.</param>
        internal static void XMLSerialize(DDNode n, XmlWriter writer)
        {
            if (n.Name != null)
            {
                writer.WriteAttributeString(DDSchema.XML_SERIALIZE_ATTRIBUTE_NAME, n.Name);
            }
            if (String.IsNullOrEmpty(n.Type) == false)
            {
                writer.WriteAttributeString(DDSchema.XML_SERIALIZE_ATTRIBUTE_TYPE, n.Type);                                        // write none empty type
            }
            if (n.Attributes != null)
            {
                DDAttributesCollectionSxe.XMLSerialize(n.Attributes, writer);
            }

            if (n.HasChildNodes)
            {
                foreach (var keyValuePair in n)
                {
                    if (keyValuePair.Value != null)
                    {
                        keyValuePair.Value.Serialize(writer);
                    }
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Converts an object into its XML representation.
 /// </summary>
 /// <param name="writer"></param>
 public virtual void WriteXml(XmlWriter writer)
 {
     DDAttributesCollectionSxe.XMLSerialize(this.ac, writer);
 }