예제 #1
0
 public virtual void BuildXmlNode(XmlDocument doc, ref XmlNode refNode, string subName)
 {
     foreach (PropertyInfo info in this.GetPropertyInfoList())
     {
         object[] customAttributes = info.GetCustomAttributes(typeof(XmlMappingAttribute), true);
         if (customAttributes.Length > 0)
         {
             XmlMappingAttribute attribute = customAttributes[0] as XmlMappingAttribute;
             if (info.PropertyType.IsSubclassOf(typeof(XmlMappingObject)))
             {
                 XmlMappingObject obj2 = info.GetValue(this, null) as XmlMappingObject;
                 if (attribute.ObjectType == XmlObjectType.List)
                 {
                     obj2.BuildXmlNode(doc, ref refNode, attribute.MappingName);
                 }
                 else
                 {
                     XmlNode node = this.CreateElement(doc, attribute.MappingName, "");
                     obj2.BuildXmlNode(doc, ref node, attribute.MappingName);
                     refNode.AppendChild(node);
                 }
                 continue;
             }
             if (attribute.ObjectType == XmlObjectType.List)
             {
                 IList list = info.GetValue(this, null) as IList;
                 foreach (object obj3 in list)
                 {
                     if (obj3 is XmlMappingObject)
                     {
                         XmlMappingObject obj4 = obj3 as XmlMappingObject;
                         if (attribute.ObjectType == XmlObjectType.List)
                         {
                             obj4.BuildXmlNode(doc, ref refNode, attribute.MappingName);
                         }
                         else
                         {
                             XmlNode node2 = this.CreateElement(doc, attribute.MappingName, "");
                             obj4.BuildXmlNode(doc, ref node2, attribute.MappingName);
                             refNode.AppendChild(node2);
                         }
                         continue;
                     }
                     if (obj3 is string)
                     {
                         XmlNode newChild = this.CreateElement(doc, attribute.MappingName, obj3);
                         refNode.AppendChild(newChild);
                     }
                 }
                 continue;
             }
             if (info.PropertyType.IsEnum)
             {
                 int num = (int)info.GetValue(this, null);
                 if (attribute.MappingType == MappingType.Attribute)
                 {
                     refNode.Attributes.Append(this.CreateAttribute(doc, attribute.MappingName, num));
                 }
                 else
                 {
                     refNode.AppendChild(this.CreateElement(doc, attribute.MappingName, num));
                 }
                 continue;
             }
             object obj5 = info.GetValue(this, null);
             if (attribute.MappingType == MappingType.Attribute)
             {
                 refNode.Attributes.Append(this.CreateAttribute(doc, attribute.MappingName, obj5));
             }
             else
             {
                 refNode.AppendChild(this.CreateElement(doc, attribute.MappingName, obj5));
             }
         }
     }
 }