Example #1
0
		public XmlAttributes (ICustomAttributeProvider provider)
		{
			object[] attributes = provider.GetCustomAttributes(false);
			foreach(object obj in attributes)
			{
				if(obj is XmlAnyAttributeAttribute)
					xmlAnyAttribute = (XmlAnyAttributeAttribute) obj;
				else if(obj is XmlAnyElementAttribute)
					xmlAnyElements.Add((XmlAnyElementAttribute) obj);
				else if(obj is XmlArrayAttribute)
					xmlArray = (XmlArrayAttribute) obj;
				else if(obj is XmlArrayItemAttribute)
					xmlArrayItems.Add((XmlArrayItemAttribute) obj);
				else if(obj is XmlAttributeAttribute)
					xmlAttribute = (XmlAttributeAttribute) obj;
				else if(obj is XmlChoiceIdentifierAttribute)
					xmlChoiceIdentifier = (XmlChoiceIdentifierAttribute) obj;
				else if(obj is DefaultValueAttribute)
					xmlDefaultValue = ((DefaultValueAttribute)obj).Value;
				else if(obj is XmlElementAttribute )
					xmlElements.Add((XmlElementAttribute ) obj);
				else if(obj is XmlEnumAttribute)
					xmlEnum = (XmlEnumAttribute) obj;
				else if(obj is XmlIgnoreAttribute)
					xmlIgnore = true;
				else if(obj is XmlNamespaceDeclarationsAttribute)
					xmlns = true;
				else if(obj is XmlRootAttribute)
					xmlRoot = (XmlRootAttribute) obj;
				else if(obj is XmlTextAttribute)
					xmlText = (XmlTextAttribute) obj;
				else if(obj is XmlTypeAttribute)
					xmlType = (XmlTypeAttribute) obj;
			}
		}
Example #2
0
        /// <include file='doc\XmlAttributes.uex' path='docs/doc[@for="XmlAttributes.XmlAttributes1"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public XmlAttributes(ICustomAttributeProvider provider)
        {
            xmlIgnore = GetAttr(provider, typeof(XmlIgnoreAttribute)) != null;
            if (!xmlIgnore)
            {
                object[] attrs = provider.GetCustomAttributes(typeof(XmlElementAttribute), false);
                for (int i = 0; i < attrs.Length; i++)
                {
                    this.xmlElements.Add((XmlElementAttribute)attrs[i]);
                }

                attrs = provider.GetCustomAttributes(typeof(XmlArrayItemAttribute), false);
                for (int i = 0; i < attrs.Length; i++)
                {
                    this.xmlArrayItems.Add((XmlArrayItemAttribute)attrs[i]);
                }

                attrs = provider.GetCustomAttributes(typeof(XmlAnyElementAttribute), false);
                for (int i = 0; i < attrs.Length; i++)
                {
                    this.xmlAnyElements.Add((XmlAnyElementAttribute)attrs[i]);
                }

                DefaultValueAttribute defaultValueAttribute = (DefaultValueAttribute)GetAttr(provider, typeof(DefaultValueAttribute));
                if (defaultValueAttribute != null)
                {
                    xmlDefaultValue = defaultValueAttribute.Value;
                }

                xmlAttribute        = (XmlAttributeAttribute)GetAttr(provider, typeof(XmlAttributeAttribute));
                xmlArray            = (XmlArrayAttribute)GetAttr(provider, typeof(XmlArrayAttribute));
                xmlText             = (XmlTextAttribute)GetAttr(provider, typeof(XmlTextAttribute));
                xmlEnum             = (XmlEnumAttribute)GetAttr(provider, typeof(XmlEnumAttribute));
                xmlRoot             = (XmlRootAttribute)GetAttr(provider, typeof(XmlRootAttribute));
                xmlType             = (XmlTypeAttribute)GetAttr(provider, typeof(XmlTypeAttribute));
                xmlAnyAttribute     = (XmlAnyAttributeAttribute)GetAttr(provider, typeof(XmlAnyAttributeAttribute));
                xmlChoiceIdentifier = (XmlChoiceIdentifierAttribute)GetAttr(provider, typeof(XmlChoiceIdentifierAttribute));
                xmlns = GetAttr(provider, typeof(XmlNamespaceDeclarationsAttribute)) != null;
            }
        }
Example #3
0
        /// <include file='doc\XmlAttributes.uex' path='docs/doc[@for="XmlAttributes.XmlAttributes1"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public XmlAttributes(MemberInfo memberInfo)
        {
            object[] attrs = memberInfo.GetCustomAttributes(false).ToArray();

            // most generic <any/> matches everithig 
            XmlAnyElementAttribute wildcard = null;
            for (int i = 0; i < attrs.Length; i++)
            {
                if (attrs[i] is XmlIgnoreAttribute || attrs[i] is ObsoleteAttribute || attrs[i].GetType() == IgnoreAttribute)
                {
                    _xmlIgnore = true;
                    break;
                }
                else if (attrs[i] is XmlElementAttribute)
                {
                    _xmlElements.Add((XmlElementAttribute)attrs[i]);
                }
                else if (attrs[i] is XmlArrayItemAttribute)
                {
                    _xmlArrayItems.Add((XmlArrayItemAttribute)attrs[i]);
                }
                else if (attrs[i] is XmlAnyElementAttribute)
                {
                    XmlAnyElementAttribute any = (XmlAnyElementAttribute)attrs[i];
                    if ((any.Name == null || any.Name.Length == 0) && any.NamespaceSpecified && any.Namespace == null)
                    {
                        // ignore duplicate wildcards
                        wildcard = any;
                    }
                    else
                    {
                        _xmlAnyElements.Add((XmlAnyElementAttribute)attrs[i]);
                    }
                }
                else if (attrs[i] is DefaultValueAttribute)
                {
                    _xmlDefaultValue = ((DefaultValueAttribute)attrs[i]).Value;
                }
                else if (attrs[i] is XmlAttributeAttribute)
                {
                    _xmlAttribute = (XmlAttributeAttribute)attrs[i];
                }
                else if (attrs[i] is XmlArrayAttribute)
                {
                    _xmlArray = (XmlArrayAttribute)attrs[i];
                }
                else if (attrs[i] is XmlTextAttribute)
                {
                    _xmlText = (XmlTextAttribute)attrs[i];
                }
                else if (attrs[i] is XmlEnumAttribute)
                {
                    _xmlEnum = (XmlEnumAttribute)attrs[i];
                }
                else if (attrs[i] is XmlRootAttribute)
                {
                    _xmlRoot = (XmlRootAttribute)attrs[i];
                }
                else if (attrs[i] is XmlTypeAttribute)
                {
                    _xmlType = (XmlTypeAttribute)attrs[i];
                }
                else if (attrs[i] is XmlAnyAttributeAttribute)
                {
                    _xmlAnyAttribute = (XmlAnyAttributeAttribute)attrs[i];
                }
                else if (attrs[i] is XmlChoiceIdentifierAttribute)
                {
                    _xmlChoiceIdentifier = (XmlChoiceIdentifierAttribute)attrs[i];
                }
                else if (attrs[i] is XmlNamespaceDeclarationsAttribute)
                {
                    _xmlns = true;
                }
            }
            if (_xmlIgnore)
            {
                _xmlElements.Clear();
                _xmlArrayItems.Clear();
                _xmlAnyElements.Clear();
                _xmlDefaultValue = null;
                _xmlAttribute = null;
                _xmlArray = null;
                _xmlText = null;
                _xmlEnum = null;
                _xmlType = null;
                _xmlAnyAttribute = null;
                _xmlChoiceIdentifier = null;
                _xmlns = false;
            }
            else
            {
                if (wildcard != null)
                {
                    _xmlAnyElements.Add(wildcard);
                }
            }
        }
Example #4
0
        /// <include file='doc\XmlAttributes.uex' path='docs/doc[@for="XmlAttributes.XmlAttributes1"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public XmlAttributes(MemberInfo memberInfo)
        {
            object[] attrs = memberInfo.GetCustomAttributes(false).ToArray();

            // most generic <any/> matches everithig
            XmlAnyElementAttribute wildcard = null;

            for (int i = 0; i < attrs.Length; i++)
            {
                if (attrs[i] is XmlIgnoreAttribute || attrs[i] is ObsoleteAttribute || attrs[i].GetType() == IgnoreAttribute)
                {
                    _xmlIgnore = true;
                    break;
                }
                else if (attrs[i] is XmlElementAttribute)
                {
                    _xmlElements.Add((XmlElementAttribute)attrs[i]);
                }
                else if (attrs[i] is XmlArrayItemAttribute)
                {
                    _xmlArrayItems.Add((XmlArrayItemAttribute)attrs[i]);
                }
                else if (attrs[i] is XmlAnyElementAttribute)
                {
                    XmlAnyElementAttribute any = (XmlAnyElementAttribute)attrs[i];
                    if ((any.Name == null || any.Name.Length == 0) && any.NamespaceSpecified && any.Namespace == null)
                    {
                        // ignore duplicate wildcards
                        wildcard = any;
                    }
                    else
                    {
                        _xmlAnyElements.Add((XmlAnyElementAttribute)attrs[i]);
                    }
                }
                else if (attrs[i] is DefaultValueAttribute)
                {
                    _xmlDefaultValue = ((DefaultValueAttribute)attrs[i]).Value;
                }
                else if (attrs[i] is XmlAttributeAttribute)
                {
                    _xmlAttribute = (XmlAttributeAttribute)attrs[i];
                }
                else if (attrs[i] is XmlArrayAttribute)
                {
                    _xmlArray = (XmlArrayAttribute)attrs[i];
                }
                else if (attrs[i] is XmlTextAttribute)
                {
                    _xmlText = (XmlTextAttribute)attrs[i];
                }
                else if (attrs[i] is XmlEnumAttribute)
                {
                    _xmlEnum = (XmlEnumAttribute)attrs[i];
                }
                else if (attrs[i] is XmlRootAttribute)
                {
                    _xmlRoot = (XmlRootAttribute)attrs[i];
                }
                else if (attrs[i] is XmlTypeAttribute)
                {
                    _xmlType = (XmlTypeAttribute)attrs[i];
                }
                else if (attrs[i] is XmlAnyAttributeAttribute)
                {
                    _xmlAnyAttribute = (XmlAnyAttributeAttribute)attrs[i];
                }
                else if (attrs[i] is XmlChoiceIdentifierAttribute)
                {
                    _xmlChoiceIdentifier = (XmlChoiceIdentifierAttribute)attrs[i];
                }
                else if (attrs[i] is XmlNamespaceDeclarationsAttribute)
                {
                    _xmlns = true;
                }
            }
            if (_xmlIgnore)
            {
                _xmlElements.Clear();
                _xmlArrayItems.Clear();
                _xmlAnyElements.Clear();
                _xmlDefaultValue     = null;
                _xmlAttribute        = null;
                _xmlArray            = null;
                _xmlText             = null;
                _xmlEnum             = null;
                _xmlType             = null;
                _xmlAnyAttribute     = null;
                _xmlChoiceIdentifier = null;
                _xmlns = false;
            }
            else
            {
                if (wildcard != null)
                {
                    _xmlAnyElements.Add(wildcard);
                }
            }
        }
Example #5
0
        public XmlAttributes(ICustomAttributeProvider provider)
        {
            object[] attributes = provider.GetCustomAttributes(false);
            foreach (object obj in attributes)
            {
                if (obj is XmlAnyAttributeAttribute)
                {
                    xmlAnyAttribute = (XmlAnyAttributeAttribute)obj;
                }
                else
                if (obj is XmlAnyElementAttribute)
                {
                    xmlAnyElements.Add((XmlAnyElementAttribute)obj);
                }
                else if (obj is XmlArrayAttribute)
                {
                    xmlArray = (XmlArrayAttribute)obj;
                }
                else if (obj is XmlArrayItemAttribute)
                {
                    xmlArrayItems.Add((XmlArrayItemAttribute)obj);
                }
                else if (obj is XmlAttributeAttribute)
                {
                    xmlAttribute = (XmlAttributeAttribute)obj;
                }
                else if (obj is XmlChoiceIdentifierAttribute)
                {
                    xmlChoiceIdentifier = (XmlChoiceIdentifierAttribute)obj;
                }
                else if (obj is DefaultValueAttribute)
                {
                    xmlDefaultValue = ((DefaultValueAttribute)obj).Value;
                }
                else if (obj is XmlElementAttribute)
                {
                    xmlElements.Add((XmlElementAttribute )obj);
                }
                else if (obj is XmlEnumAttribute)
                {
                    xmlEnum = (XmlEnumAttribute)obj;
                }
                else if (obj is XmlIgnoreAttribute)
                {
                    xmlIgnore = true;
                }
                else if (obj is XmlNamespaceDeclarationsAttribute)
                {
                    xmlns = true;
                }
                else if (obj is XmlRootAttribute)
                {
                    xmlRoot = (XmlRootAttribute)obj;
                }
                else if (obj is XmlTextAttribute)
                {
                    xmlText = (XmlTextAttribute)obj;
                }
                else if (obj is XmlTypeAttribute)
                {
                    xmlType = (XmlTypeAttribute)obj;
                }
            }

            if (xmlIgnore)
            {
                xmlAnyAttribute = null;
                xmlAnyElements.Clear();
                xmlArray = null;
                xmlArrayItems.Clear();
                xmlAttribute        = null;
                xmlChoiceIdentifier = null;
                xmlDefaultValue     = null;
                xmlElements.Clear();
                xmlEnum = null;
                xmlns   = false;
                xmlRoot = null;
                xmlText = null;
                xmlType = null;
            }
        }
Example #6
0
        /// <include file='doc\XmlAttributes.uex' path='docs/doc[@for="XmlAttributes.XmlAttributes1"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public XmlAttributes(ICustomAttributeProvider provider) {
            xmlIgnore = GetAttr(provider, typeof(XmlIgnoreAttribute)) != null;
            if (!xmlIgnore) {

                object[] attrs = provider.GetCustomAttributes(typeof(XmlElementAttribute), false);
                for (int i = 0; i < attrs.Length; i++)
                    this.xmlElements.Add((XmlElementAttribute)attrs[i]);

                attrs = provider.GetCustomAttributes(typeof(XmlArrayItemAttribute), false);
                for (int i = 0; i < attrs.Length; i++)
                    this.xmlArrayItems.Add((XmlArrayItemAttribute)attrs[i]);

                attrs = provider.GetCustomAttributes(typeof(XmlAnyElementAttribute), false);
                for (int i = 0; i < attrs.Length; i++)
                    this.xmlAnyElements.Add((XmlAnyElementAttribute)attrs[i]);

                DefaultValueAttribute defaultValueAttribute = (DefaultValueAttribute)GetAttr(provider, typeof(DefaultValueAttribute));
                if (defaultValueAttribute != null) xmlDefaultValue = defaultValueAttribute.Value;

                xmlAttribute = (XmlAttributeAttribute)GetAttr(provider, typeof(XmlAttributeAttribute));
                xmlArray = (XmlArrayAttribute)GetAttr(provider, typeof(XmlArrayAttribute));
                xmlText = (XmlTextAttribute)GetAttr(provider, typeof(XmlTextAttribute));
                xmlEnum = (XmlEnumAttribute)GetAttr(provider, typeof(XmlEnumAttribute));
                xmlRoot = (XmlRootAttribute)GetAttr(provider, typeof(XmlRootAttribute));
                xmlType = (XmlTypeAttribute)GetAttr(provider, typeof(XmlTypeAttribute));
                xmlAnyAttribute = (XmlAnyAttributeAttribute)GetAttr(provider, typeof(XmlAnyAttributeAttribute));
                xmlChoiceIdentifier = (XmlChoiceIdentifierAttribute)GetAttr(provider, typeof(XmlChoiceIdentifierAttribute));
                xmlns = GetAttr(provider, typeof(XmlNamespaceDeclarationsAttribute)) != null;
            }
        }
Example #7
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);
            }
        }