Inheritance: System.Attribute
 /// <include file='doc\SoapAttributes.uex' path='docs/doc[@for="SoapAttributes.SoapAttributes1"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public SoapAttributes(ICustomAttributeProvider provider) {
     object[] attrs = provider.GetCustomAttributes(false);
     for (int i = 0; i < attrs.Length; i++) {
         if (attrs[i] is SoapIgnoreAttribute || attrs[i] is ObsoleteAttribute) {
             this.soapIgnore = true;
             break;
         }
         else if (attrs[i] is SoapElementAttribute) {
             this.soapElement = (SoapElementAttribute)attrs[i];
         }
         else if (attrs[i] is SoapAttributeAttribute) {
             this.soapAttribute = (SoapAttributeAttribute)attrs[i];
         }
         else if (attrs[i] is SoapTypeAttribute) {
             this.soapType = (SoapTypeAttribute)attrs[i];
         }
         else if (attrs[i] is SoapEnumAttribute) {
             this.soapEnum = (SoapEnumAttribute)attrs[i];
         }
         else if (attrs[i] is DefaultValueAttribute) {
             this.soapDefaultValue = ((DefaultValueAttribute)attrs[i]).Value;
         }
     }
     if (soapIgnore) {
         this.soapElement = null;
         this.soapAttribute = null;
         this.soapType = null;
         this.soapEnum = null;
         this.soapDefaultValue = null;
     }
 }
Ejemplo n.º 2
0
 /// <summary>Initializes a new instance of the <see cref="T:System.Xml.Serialization.SoapAttributes" /> class using the specified custom type.</summary>
 /// <param name="provider">Any object that implements the <see cref="T:System.Reflection.ICustomAttributeProvider" /> interface, such as the <see cref="T:System.Type" /> class. </param>
 public SoapAttributes(ICustomAttributeProvider provider)
 {
     object[] customAttributes = provider.GetCustomAttributes(false);
     foreach (object obj in customAttributes)
     {
         if (obj is SoapAttributeAttribute)
         {
             this.soapAttribute = (SoapAttributeAttribute)obj;
         }
         else if (obj is DefaultValueAttribute)
         {
             this.soapDefaultValue = ((DefaultValueAttribute)obj).Value;
         }
         else if (obj is SoapElementAttribute)
         {
             this.soapElement = (SoapElementAttribute)obj;
         }
         else if (obj is SoapEnumAttribute)
         {
             this.soapEnum = (SoapEnumAttribute)obj;
         }
         else if (obj is SoapIgnoreAttribute)
         {
             this.soapIgnore = true;
         }
         else if (obj is SoapTypeAttribute)
         {
             this.soapType = (SoapTypeAttribute)obj;
         }
     }
 }
Ejemplo n.º 3
0
		public void ElementNameDefault ()
		{
			SoapElementAttribute attr = new SoapElementAttribute ();
			Assert.AreEqual (string.Empty, attr.ElementName, "#1");

			attr.ElementName = null;
			Assert.AreEqual (string.Empty, attr.ElementName, "#2");
		}
Ejemplo n.º 4
0
        /// <include file='doc\SoapAttributes.uex' path='docs/doc[@for="SoapAttributes.SoapAttributes1"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public SoapAttributes(ICustomAttributeProvider provider) {
            soapIgnore = GetAttr(provider, typeof(SoapIgnoreAttribute)) != null;
            if (!soapIgnore) {
                soapElement = (SoapElementAttribute)GetAttr(provider, typeof(SoapElementAttribute));
                soapAttribute = (SoapAttributeAttribute)GetAttr(provider, typeof(SoapAttributeAttribute));
                soapType = (SoapTypeAttribute)GetAttr(provider, typeof(SoapTypeAttribute));
                soapEnum = (SoapEnumAttribute)GetAttr(provider, typeof(SoapEnumAttribute));

                DefaultValueAttribute defaultValueAttribute = (DefaultValueAttribute)GetAttr(provider, typeof(DefaultValueAttribute));
                if (defaultValueAttribute != null) soapDefaultValue = defaultValueAttribute.Value;
            }
        }
Ejemplo n.º 5
0
        /// <include file='doc\SoapAttributes.uex' path='docs/doc[@for="SoapAttributes.SoapAttributes1"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public SoapAttributes(ICustomAttributeProvider provider)
        {
            soapIgnore = GetAttr(provider, typeof(SoapIgnoreAttribute)) != null;
            if (!soapIgnore)
            {
                soapElement   = (SoapElementAttribute)GetAttr(provider, typeof(SoapElementAttribute));
                soapAttribute = (SoapAttributeAttribute)GetAttr(provider, typeof(SoapAttributeAttribute));
                soapType      = (SoapTypeAttribute)GetAttr(provider, typeof(SoapTypeAttribute));
                soapEnum      = (SoapEnumAttribute)GetAttr(provider, typeof(SoapEnumAttribute));

                DefaultValueAttribute defaultValueAttribute = (DefaultValueAttribute)GetAttr(provider, typeof(DefaultValueAttribute));
                if (defaultValueAttribute != null)
                {
                    soapDefaultValue = defaultValueAttribute.Value;
                }
            }
        }
Ejemplo n.º 6
0
		public SoapAttributes (ICustomAttributeProvider provider)
		{
			object[] attributes = provider.GetCustomAttributes(false);
			foreach(object obj in attributes)
			{
				if(obj is SoapAttributeAttribute)
					soapAttribute = (SoapAttributeAttribute) obj;
				else if(obj is DefaultValueAttribute)
					soapDefaultValue = ((DefaultValueAttribute) obj).Value;
				else if(obj is SoapElementAttribute)
					soapElement = (SoapElementAttribute) obj;
				else if(obj is SoapEnumAttribute)
					soapEnum = (SoapEnumAttribute) obj;
				else if(obj is SoapIgnoreAttribute)
					soapIgnore = true;
				else if(obj is SoapTypeAttribute)
					soapType = (SoapTypeAttribute) obj;
			}
		}
Ejemplo n.º 7
0
 /// <include file='doc\SoapAttributes.uex' path='docs/doc[@for="SoapAttributes.SoapAttributes1"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public SoapAttributes(ICustomAttributeProvider provider)
 {
     object[] attrs = provider.GetCustomAttributes(false);
     for (int i = 0; i < attrs.Length; i++)
     {
         if (attrs[i] is SoapIgnoreAttribute || attrs[i] is ObsoleteAttribute)
         {
             this.soapIgnore = true;
             break;
         }
         else if (attrs[i] is SoapElementAttribute)
         {
             this.soapElement = (SoapElementAttribute)attrs[i];
         }
         else if (attrs[i] is SoapAttributeAttribute)
         {
             this.soapAttribute = (SoapAttributeAttribute)attrs[i];
         }
         else if (attrs[i] is SoapTypeAttribute)
         {
             this.soapType = (SoapTypeAttribute)attrs[i];
         }
         else if (attrs[i] is SoapEnumAttribute)
         {
             this.soapEnum = (SoapEnumAttribute)attrs[i];
         }
         else if (attrs[i] is DefaultValueAttribute)
         {
             this.soapDefaultValue = ((DefaultValueAttribute)attrs[i]).Value;
         }
     }
     if (soapIgnore)
     {
         this.soapElement      = null;
         this.soapAttribute    = null;
         this.soapType         = null;
         this.soapEnum         = null;
         this.soapDefaultValue = null;
     }
 }
Ejemplo n.º 8
0
 /// <include file='doc\SoapAttributes.uex' path='docs/doc[@for="SoapAttributes.SoapAttributes1"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public SoapAttributes(MemberInfo memberInfo)
 {
     foreach (Attribute attr in memberInfo.GetCustomAttributes(false))
     {
         if (attr is SoapIgnoreAttribute || attr is ObsoleteAttribute)
         {
             _soapIgnore = true;
             break;
         }
         else if (attr is SoapElementAttribute)
         {
             _soapElement = (SoapElementAttribute)attr;
         }
         else if (attr is SoapAttributeAttribute)
         {
             _soapAttribute = (SoapAttributeAttribute)attr;
         }
         else if (attr is SoapTypeAttribute)
         {
             _soapType = (SoapTypeAttribute)attr;
         }
         else if (attr is SoapEnumAttribute)
         {
             _soapEnum = (SoapEnumAttribute)attr;
         }
         else if (attr is DefaultValueAttribute)
         {
             _soapDefaultValue = ((DefaultValueAttribute)attr).Value;
         }
     }
     if (_soapIgnore)
     {
         _soapElement      = null;
         _soapAttribute    = null;
         _soapType         = null;
         _soapEnum         = null;
         _soapDefaultValue = null;
     }
 }
Ejemplo n.º 9
0
 /// <include file='doc\SoapAttributes.uex' path='docs/doc[@for="SoapAttributes.SoapAttributes1"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public SoapAttributes(MemberInfo memberInfo)
 {
     foreach (Attribute attr in memberInfo.GetCustomAttributes(false))
     {
         if (attr is SoapIgnoreAttribute || attr is ObsoleteAttribute)
         {
             _soapIgnore = true;
             break;
         }
         else if (attr is SoapElementAttribute)
         {
             _soapElement = (SoapElementAttribute)attr;
         }
         else if (attr is SoapAttributeAttribute)
         {
             _soapAttribute = (SoapAttributeAttribute)attr;
         }
         else if (attr is SoapTypeAttribute)
         {
             _soapType = (SoapTypeAttribute)attr;
         }
         else if (attr is SoapEnumAttribute)
         {
             _soapEnum = (SoapEnumAttribute)attr;
         }
         else if (attr is DefaultValueAttribute)
         {
             _soapDefaultValue = ((DefaultValueAttribute)attr).Value;
         }
     }
     if (_soapIgnore)
     {
         _soapElement = null;
         _soapAttribute = null;
         _soapType = null;
         _soapEnum = null;
         _soapDefaultValue = null;
     }
 }
Ejemplo n.º 10
0
		[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
/*
#if NET_2_0
		[Category ("NotWorking")] // minOccurs is 1 on Mono
#endif
 */
		public void ExportClass_SimpleClass_Array ()
		{
			SoapAttributeOverrides overrides = new SoapAttributeOverrides ();
			SoapAttributes attr = new SoapAttributes ();
			SoapElementAttribute element = new SoapElementAttribute ();
			element.ElementName = "saying";
			element.IsNullable = true;
			attr.SoapElement = element;
			overrides.Add (typeof (SimpleClass), "something", attr);

			SoapReflectionImporter ri = new SoapReflectionImporter (overrides, "NSSimpleClassArray");
			XmlSchemas schemas = new XmlSchemas ();
			SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
			XmlTypeMapping tm = ri.ImportTypeMapping (typeof (SimpleClass[]));
			sx.ExportTypeMapping (tm);

			Assert.AreEqual (1, schemas.Count, "#1");

			StringWriter sw = new StringWriter ();
			schemas[0].Write (sw);

			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
#if NET_2_0
				"<xs:schema xmlns:tns=\"NSSimpleClassArray\" elementFormDefault=\"qualified\" targetNamespace=\"NSSimpleClassArray\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
#else
				"<xs:schema xmlns:tns=\"NSSimpleClassArray\" targetNamespace=\"NSSimpleClassArray\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
#endif
				"  <xs:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" />{0}" +
				"  <xs:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
				"  <xs:complexType name=\"ArrayOfSimpleClass\">{0}" +
				"    <xs:complexContent mixed=\"false\">{0}" +
				"      <xs:restriction xmlns:q1=\"http://schemas.xmlsoap.org/soap/encoding/\" base=\"q1:Array\">{0}" +
				"        <xs:attribute d5p1:arrayType=\"tns:SimpleClass[]\" ref=\"q1:arrayType\" xmlns:d5p1=\"http://schemas.xmlsoap.org/wsdl/\" />{0}" +
				"      </xs:restriction>{0}" +
				"    </xs:complexContent>{0}" +
				"  </xs:complexType>{0}" +
				"  <xs:complexType name=\"SimpleClass\">{0}" +
				"    <xs:sequence>{0}" +
#if NET_2_0
				"      <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"saying\" nillable=\"true\" type=\"xs:string\" />{0}" +
#else
				"      <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"saying\" type=\"xs:string\" />{0}" +
#endif
				"    </xs:sequence>{0}" +
				"  </xs:complexType>{0}" +
				"</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
		}
Ejemplo n.º 11
0
		[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
/*
#if NET_2_0
		[Category ("NotWorking")] // minOccurs is 1 on Mono
#endif
*/
		public void ExportClass_SimpleClass ()
		{
			SoapAttributeOverrides overrides = new SoapAttributeOverrides ();
			SoapAttributes attr = new SoapAttributes ();
			SoapElementAttribute element = new SoapElementAttribute ();
			element.ElementName = "saying";
			element.IsNullable = true;
			attr.SoapElement = element;
			overrides.Add (typeof (SimpleClass), "something", attr);

			XmlSchemas schemas = Export (typeof (SimpleClass), overrides, "NSSimpleClass");
			Assert.AreEqual (1, schemas.Count, "#1");

			StringWriter sw = new StringWriter ();
			schemas[0].Write (sw);

			Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
				"<?xml version=\"1.0\" encoding=\"utf-16\"?>{0}" +
#if NET_2_0
				"<xs:schema xmlns:tns=\"NSSimpleClass\" elementFormDefault=\"qualified\" targetNamespace=\"NSSimpleClass\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
#else
				"<xs:schema xmlns:tns=\"NSSimpleClass\" targetNamespace=\"NSSimpleClass\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">{0}" +
#endif
				"  <xs:complexType name=\"SimpleClass\">{0}" +
				"    <xs:sequence>{0}" +
#if NET_2_0
				"      <xs:element minOccurs=\"0\" maxOccurs=\"1\" form=\"unqualified\" name=\"saying\" nillable=\"true\" type=\"xs:string\" />{0}" +
#else
				"      <xs:element minOccurs=\"1\" maxOccurs=\"1\" name=\"saying\" type=\"xs:string\" />{0}" +
#endif
				"    </xs:sequence>{0}" +
				"  </xs:complexType>{0}" +
				"</xs:schema>", Environment.NewLine), sw.ToString (), "#2");
		}
Ejemplo n.º 12
0
		public void IsNullableDefault ()
		{
			SoapElementAttribute attr = new SoapElementAttribute ();
			Assert.AreEqual (false, attr.IsNullable);
		}