示例#1
0
 public XmlAttributes()
 {
     this.xmlElements    = new XmlElementAttributes();
     this.xmlArrayItems  = new XmlArrayItemAttributes();
     this.xmlAnyElements = new XmlAnyElementAttributes();
 }
示例#2
0
        public XmlAttributes(ICustomAttributeProvider provider)
        {
            this.xmlElements    = new XmlElementAttributes();
            this.xmlArrayItems  = new XmlArrayItemAttributes();
            this.xmlAnyElements = new XmlAnyElementAttributes();
            object[] customAttributes        = provider.GetCustomAttributes(false);
            XmlAnyElementAttribute attribute = null;

            for (int i = 0; i < customAttributes.Length; i++)
            {
                if (((customAttributes[i] is XmlIgnoreAttribute) || (customAttributes[i] is ObsoleteAttribute)) || (customAttributes[i].GetType() == IgnoreAttribute))
                {
                    this.xmlIgnore = true;
                    break;
                }
                if (customAttributes[i] is XmlElementAttribute)
                {
                    this.xmlElements.Add((XmlElementAttribute)customAttributes[i]);
                }
                else if (customAttributes[i] is XmlArrayItemAttribute)
                {
                    this.xmlArrayItems.Add((XmlArrayItemAttribute)customAttributes[i]);
                }
                else if (customAttributes[i] is XmlAnyElementAttribute)
                {
                    XmlAnyElementAttribute attribute2 = (XmlAnyElementAttribute)customAttributes[i];
                    if (((attribute2.Name == null) || (attribute2.Name.Length == 0)) && (attribute2.NamespaceSpecified && (attribute2.Namespace == null)))
                    {
                        attribute = attribute2;
                    }
                    else
                    {
                        this.xmlAnyElements.Add((XmlAnyElementAttribute)customAttributes[i]);
                    }
                }
                else if (customAttributes[i] is DefaultValueAttribute)
                {
                    this.xmlDefaultValue = ((DefaultValueAttribute)customAttributes[i]).Value;
                }
                else if (customAttributes[i] is XmlAttributeAttribute)
                {
                    this.xmlAttribute = (XmlAttributeAttribute)customAttributes[i];
                }
                else if (customAttributes[i] is XmlArrayAttribute)
                {
                    this.xmlArray = (XmlArrayAttribute)customAttributes[i];
                }
                else if (customAttributes[i] is XmlTextAttribute)
                {
                    this.xmlText = (XmlTextAttribute)customAttributes[i];
                }
                else if (customAttributes[i] is XmlEnumAttribute)
                {
                    this.xmlEnum = (XmlEnumAttribute)customAttributes[i];
                }
                else if (customAttributes[i] is XmlRootAttribute)
                {
                    this.xmlRoot = (XmlRootAttribute)customAttributes[i];
                }
                else if (customAttributes[i] is XmlTypeAttribute)
                {
                    this.xmlType = (XmlTypeAttribute)customAttributes[i];
                }
                else if (customAttributes[i] is XmlAnyAttributeAttribute)
                {
                    this.xmlAnyAttribute = (XmlAnyAttributeAttribute)customAttributes[i];
                }
                else if (customAttributes[i] is XmlChoiceIdentifierAttribute)
                {
                    this.xmlChoiceIdentifier = (XmlChoiceIdentifierAttribute)customAttributes[i];
                }
                else if (customAttributes[i] is XmlNamespaceDeclarationsAttribute)
                {
                    this.xmlns = true;
                }
            }
            if (this.xmlIgnore)
            {
                this.xmlElements.Clear();
                this.xmlArrayItems.Clear();
                this.xmlAnyElements.Clear();
                this.xmlDefaultValue     = null;
                this.xmlAttribute        = null;
                this.xmlArray            = null;
                this.xmlText             = null;
                this.xmlEnum             = null;
                this.xmlType             = null;
                this.xmlAnyAttribute     = null;
                this.xmlChoiceIdentifier = null;
                this.xmlns = false;
            }
            else if (attribute != null)
            {
                this.xmlAnyElements.Add(attribute);
            }
        }
		private static void AddXmlAnyElementsPrint(XmlAnyElementAttributes atts, StringBuilder printBuilder)
		{
			if (null != atts)
			{
				foreach (XmlAnyElementAttribute att in atts)
				{
					printBuilder.Append("anyatt");
					printBuilder.Append("/");
					printBuilder.Append(att.Name);
					printBuilder.Append("/");
					printBuilder.Append(att.Namespace);
					printBuilder.Append("::");
				}
			}
			printBuilder.Append("%%");
		}