Exemplo n.º 1
0
 public SoapReflectionImporter(SoapAttributeOverrides?attributeOverrides, string?defaultNamespace)
 {
     _defaultNs          = defaultNamespace ?? string.Empty;
     _attributeOverrides = attributeOverrides ?? new SoapAttributeOverrides();
     _typeScope          = new TypeScope();
     _modelScope         = new ModelScope(_typeScope);
 }
		private XmlTypeMapping Map (Type t, SoapAttributeOverrides overrides)
		{
			SoapReflectionImporter ri = new SoapReflectionImporter(overrides);
			XmlTypeMapping tm = ri.ImportTypeMapping(t);

			return tm;
		}
Exemplo n.º 3
0
		public SoapReflectionImporter (SoapAttributeOverrides attributeOverrides, string defaultNamespace)
		{ 
			if (defaultNamespace == null) initialDefaultNamespace = String.Empty;
			else initialDefaultNamespace = defaultNamespace;

			if (attributeOverrides == null) this.attributeOverrides = new SoapAttributeOverrides();
			else this.attributeOverrides = attributeOverrides;
		}
		private XmlMembersMapping MembersMap (Type t, SoapAttributeOverrides overrides, 
			XmlReflectionMember [] members, bool inContainer, bool writeAccessors)
		{
			SoapReflectionImporter ri = new SoapReflectionImporter (overrides);
			XmlMembersMapping mm = ri.ImportMembersMapping (null, null, members, 
				inContainer, writeAccessors);
			
			return mm;
		}
Exemplo n.º 5
0
		private XmlSchemas Export (Type type, SoapAttributeOverrides overrides, string defaultNamespace)
		{
			SoapReflectionImporter ri = new SoapReflectionImporter (overrides, defaultNamespace);
			XmlSchemas schemas = new XmlSchemas ();
			SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
			XmlTypeMapping tm = ri.ImportTypeMapping (type);
			sx.ExportTypeMapping (tm);
			return schemas;
		}
 /// <include file='doc\SoapReflectionImporter.uex' path='docs/doc[@for="SoapReflectionImporter.SoapReflectionImporter3"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public SoapReflectionImporter(SoapAttributeOverrides attributeOverrides, string defaultNamespace) {
     if (defaultNamespace == null)
         defaultNamespace = String.Empty;
     if (attributeOverrides == null)
         attributeOverrides = new SoapAttributeOverrides();
     this.attributeOverrides = attributeOverrides;
     this.defaultNs = defaultNamespace;
     this.typeScope = new TypeScope();
     this.modelScope = new ModelScope(this.typeScope);
 }
 public SoapTypeSerializationSource(Type type, SoapAttributeOverrides attributeOverrides, string namspace, Type[] includedTypes) : base(namspace, includedTypes)
 {
     if (attributeOverrides != null)
     {
         StringBuilder stringBuilder = new StringBuilder();
         attributeOverrides.AddKeyHash(stringBuilder);
         this.attributeOverridesHash = stringBuilder.ToString();
     }
     this.type = type;
 }
Exemplo n.º 8
0
 /// <include file='doc\SoapReflectionImporter.uex' path='docs/doc[@for="SoapReflectionImporter.SoapReflectionImporter3"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public SoapReflectionImporter(SoapAttributeOverrides attributeOverrides, string defaultNamespace)
 {
     if (defaultNamespace == null)
     {
         defaultNamespace = String.Empty;
     }
     if (attributeOverrides == null)
     {
         attributeOverrides = new SoapAttributeOverrides();
     }
     _attributeOverrides = attributeOverrides;
     _defaultNs          = defaultNamespace;
     _typeScope          = new TypeScope();
     _modelScope         = new ModelScope(_typeScope);
 }
Exemplo n.º 9
0
 public SoapReflectionImporter(SoapAttributeOverrides attributeOverrides, string defaultNamespace)
 {
     this.types     = new System.Xml.Serialization.NameTable();
     this.nullables = new System.Xml.Serialization.NameTable();
     if (defaultNamespace == null)
     {
         defaultNamespace = string.Empty;
     }
     if (attributeOverrides == null)
     {
         attributeOverrides = new SoapAttributeOverrides();
     }
     this.attributeOverrides = attributeOverrides;
     this.defaultNs          = defaultNamespace;
     this.typeScope          = new TypeScope();
     this.modelScope         = new ModelScope(this.typeScope);
 }
Exemplo n.º 10
0
 /// <summary>Initializes a new instance of the <see cref="T:System.Xml.Serialization.SoapReflectionImporter" /> class, specifying XML serialization overrides and a default XML namespace. </summary>
 /// <param name="attributeOverrides">A <see cref="T:System.Xml.Serialization.SoapAttributeOverrides" /> object that overrides how the <see cref="T:System.Xml.Serialization.XmlSerializer" /> class serializes mapped types using SOAP encoding.</param>
 /// <param name="defaultNamespace">The default XML namespace to use for imported type mappings.</param>
 public SoapReflectionImporter(SoapAttributeOverrides attributeOverrides, string defaultNamespace)
 {
     if (defaultNamespace == null)
     {
         this.initialDefaultNamespace = string.Empty;
     }
     else
     {
         this.initialDefaultNamespace = defaultNamespace;
     }
     if (attributeOverrides == null)
     {
         this.attributeOverrides = new SoapAttributeOverrides();
     }
     else
     {
         this.attributeOverrides = attributeOverrides;
     }
 }
Exemplo n.º 11
0
 /// <include file='doc\SoapReflectionImporter.uex' path='docs/doc[@for="SoapReflectionImporter.SoapReflectionImporter2"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public SoapReflectionImporter(SoapAttributeOverrides attributeOverrides) : this(attributeOverrides, null)
 {
 }
		public SoapTypeSerializationSource (Type type, SoapAttributeOverrides attributeOverrides, string namspace, ArrayList includedTypes)
		: base (namspace, includedTypes)
		{
			if (attributeOverrides != null) {
				StringBuilder sb = new StringBuilder ();
				attributeOverrides.AddKeyHash (sb);
				attributeOverridesHash = sb.ToString ();
			}
			
			this.type = type;
		}
Exemplo n.º 13
0
		static XmlTypeMapping CreateSoapMapping (Type type, SoapAttributeOverrides ao, string defaultNamespace)
		{
			SoapReflectionImporter importer = new SoapReflectionImporter (ao, defaultNamespace);
			return importer.ImportTypeMapping (type);
		}
Exemplo n.º 14
0
		static XmlTypeMapping CreateSoapMapping (Type type, SoapAttributeOverrides ao)
		{
			SoapReflectionImporter importer = new SoapReflectionImporter (ao);
			return importer.ImportTypeMapping (type);
		}
Exemplo n.º 15
0
		[Category ("NotWorking")] // SerializationCodeGenerator outputs wrong xsi:type for flagencoded in #C1
		public void TestSerializeDefaultValueAttribute_Encoded ()
		{
			SoapAttributeOverrides overrides = new SoapAttributeOverrides ();
			SoapAttributes attr = new SoapAttributes ();
			attr.SoapAttribute = new SoapAttributeAttribute ();
			string defaultValueInstance = "nothing";
			attr.SoapDefaultValue = defaultValueInstance;
			overrides.Add (typeof (SimpleClass), "something", attr);

			// use the default
			SimpleClass simple = new SimpleClass ();
			SerializeEncoded (simple, overrides);
			Assert.AreEqual (Infoset ("<SimpleClass id='id1' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />"), WriterText, "#A1");

			// same value as default
			simple.something = defaultValueInstance;
			SerializeEncoded (simple, overrides);
			Assert.AreEqual (Infoset ("<SimpleClass id='id1' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />"), WriterText, "#A2");

			// some other value
			simple.something = "hello";
			SerializeEncoded (simple, overrides);
			Assert.AreEqual (Infoset ("<SimpleClass id='id1' something='hello' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />"), WriterText, "#A3");

			attr.SoapAttribute = null;
			attr.SoapElement = new SoapElementAttribute ();

			// use the default
			simple = new SimpleClass ();
			SerializeEncoded (simple, overrides);
			Assert.AreEqual (Infoset ("<SimpleClass id='id1' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' />"), WriterText, "#B1");

			// same value as default
			simple.something = defaultValueInstance;
			SerializeEncoded (simple, overrides);
			Assert.AreEqual (Infoset ("<SimpleClass id='id1' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><something xsi:type='xsd:string'>nothing</something></SimpleClass>"), WriterText, "#B2");

			// some other value
			simple.something = "hello";
			SerializeEncoded (simple, overrides);
			Assert.AreEqual (Infoset ("<SimpleClass id='id1' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><something xsi:type='xsd:string'>hello</something></SimpleClass>"), WriterText, "#B3");

			overrides = new SoapAttributeOverrides ();
			attr = new SoapAttributes ();
			attr.SoapElement = new SoapElementAttribute ("flagenc");
			overrides.Add (typeof (TestDefault), "flagencoded", attr);

			// use the default (from MS KB325691)
			TestDefault testDefault = new TestDefault ();
			SerializeEncoded (testDefault);
			Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
				"<q1:testDefault id='id1' xmlns:q1='urn:myNS' xmlns:xsd='{0}' xmlns:xsi='{1}'>" +
				"    <strDefault xsi:type='xsd:string'>Default Value</strDefault>" +
				"    <boolT xsi:type='xsd:boolean'>true</boolT>" +
				"    <boolF xsi:type='xsd:boolean'>false</boolF>" +
				"    <decimalval xsi:type='xsd:decimal'>10</decimalval>" +
				"    <flag xsi:type='FlagEnum'>e1 e4</flag>" +
				"    <flagencoded xsi:type='flagenum'>one four</flagencoded>" +
				"</q1:testDefault>", XmlSchema.Namespace, XmlSchema.InstanceNamespace)),
				WriterText, "#C1");

			SerializeEncoded (testDefault, overrides);
			Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
				"<q1:testDefault id='id1' xmlns:q1='urn:myNS' xmlns:xsd='{0}' xmlns:xsi='{1}'>" +
				"    <strDefault xsi:type='xsd:string'>Default Value</strDefault>" +
				"    <boolT xsi:type='xsd:boolean'>true</boolT>" +
				"    <boolF xsi:type='xsd:boolean'>false</boolF>" +
				"    <decimalval xsi:type='xsd:decimal'>10</decimalval>" +
				"    <flag xsi:type='FlagEnum'>e1 e4</flag>" +
				"    <flagenc xsi:type='flagenum'>one four</flagenc>" +
				"</q1:testDefault>", XmlSchema.Namespace, XmlSchema.InstanceNamespace)),
				WriterText, "#C2");

			SerializeEncoded (testDefault, overrides, AnotherNamespace);
			Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
				"<q1:testDefault id='id1' xmlns:q1='urn:myNS' xmlns:xsd='{0}' xmlns:xsi='{1}'>" +
				"    <strDefault xsi:type='xsd:string'>Default Value</strDefault>" +
				"    <boolT xsi:type='xsd:boolean'>true</boolT>" +
				"    <boolF xsi:type='xsd:boolean'>false</boolF>" +
				"    <decimalval xsi:type='xsd:decimal'>10</decimalval>" +
				"    <flag xmlns:q2='{2}' xsi:type='q2:FlagEnum'>e1 e4</flag>" +
				"    <flagenc xmlns:q3='{2}' xsi:type='q3:flagenum'>one four</flagenc>" +
				"</q1:testDefault>", XmlSchema.Namespace, XmlSchema.InstanceNamespace,
				AnotherNamespace)), WriterText, "#C3");

			// non-default values
			testDefault.strDefault = "Some Text";
			testDefault.boolT = false;
			testDefault.boolF = true;
			testDefault.decimalval = 20m;
			testDefault.flag = FlagEnum.e2;
			testDefault.flagencoded = FlagEnum_Encoded.e2 | FlagEnum_Encoded.e1;
			SerializeEncoded (testDefault);
			Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
				"<q1:testDefault id='id1' xmlns:q1='urn:myNS' xmlns:xsd='{0}' xmlns:xsi='{1}'>" +
				"    <strDefault xsi:type='xsd:string'>Some Text</strDefault>" +
				"    <boolT xsi:type='xsd:boolean'>false</boolT>" +
				"    <boolF xsi:type='xsd:boolean'>true</boolF>" +
				"    <decimalval xsi:type='xsd:decimal'>20</decimalval>" +
				"    <flag xsi:type='FlagEnum'>e2</flag>" +
				"    <flagencoded xsi:type='flagenum'>one two</flagencoded>" +
				"</q1:testDefault>", XmlSchema.Namespace, XmlSchema.InstanceNamespace)),
				WriterText, "#C4");

			SerializeEncoded (testDefault, overrides);
			Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
				"<q1:testDefault id='id1' xmlns:q1='urn:myNS' xmlns:xsd='{0}' xmlns:xsi='{1}'>" +
				"    <strDefault xsi:type='xsd:string'>Some Text</strDefault>" +
				"    <boolT xsi:type='xsd:boolean'>false</boolT>" +
				"    <boolF xsi:type='xsd:boolean'>true</boolF>" +
				"    <decimalval xsi:type='xsd:decimal'>20</decimalval>" +
				"    <flag xsi:type='FlagEnum'>e2</flag>" +
				"    <flagenc xsi:type='flagenum'>one two</flagenc>" +
				"</q1:testDefault>", XmlSchema.Namespace, XmlSchema.InstanceNamespace)),
				WriterText, "#C5");

			attr = new SoapAttributes ();
			attr.SoapType = new SoapTypeAttribute ("flagenum", "yetanother:urn");
			overrides.Add (typeof (FlagEnum_Encoded), attr);

			SerializeEncoded (testDefault, overrides, AnotherNamespace);
			Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
				"<q1:testDefault id='id1' xmlns:q1='urn:myNS' xmlns:xsd='{0}' xmlns:xsi='{1}'>" +
				"    <strDefault xsi:type='xsd:string'>Some Text</strDefault>" +
				"    <boolT xsi:type='xsd:boolean'>false</boolT>" +
				"    <boolF xsi:type='xsd:boolean'>true</boolF>" +
				"    <decimalval xsi:type='xsd:decimal'>20</decimalval>" +
				"    <flag xmlns:q2='{2}' xsi:type='q2:FlagEnum'>e2</flag>" +
				"    <flagenc xmlns:q3='yetanother:urn' xsi:type='q3:flagenum'>one two</flagenc>" +
				"</q1:testDefault>", XmlSchema.Namespace, XmlSchema.InstanceNamespace,
				AnotherNamespace)), WriterText, "#C6");

			attr = new SoapAttributes ();
			attr.SoapType = new SoapTypeAttribute ("testDefault");
			overrides.Add (typeof (TestDefault), attr);

			SerializeEncoded (testDefault, overrides, AnotherNamespace);
			Assert.AreEqual (Infoset (string.Format (CultureInfo.InvariantCulture,
				"<q1:testDefault id='id1' xmlns:q1='{2}' xmlns:xsd='{0}' xmlns:xsi='{1}'>" +
				"    <strDefault xsi:type='xsd:string'>Some Text</strDefault>" +
				"    <boolT xsi:type='xsd:boolean'>false</boolT>" +
				"    <boolF xsi:type='xsd:boolean'>true</boolF>" +
				"    <decimalval xsi:type='xsd:decimal'>20</decimalval>" +
				"    <flag xsi:type='q1:FlagEnum'>e2</flag>" +
				"    <flagenc xmlns:q2='yetanother:urn' xsi:type='q2:flagenum'>one two</flagenc>" +
				"</q1:testDefault>", XmlSchema.Namespace, XmlSchema.InstanceNamespace,
				AnotherNamespace)), WriterText, "#C7");
		}
Exemplo n.º 16
0
		private XmlSchemas Export (Type type, SoapAttributeOverrides overrides)
		{
			return Export (type, overrides, string.Empty);
		}
Exemplo n.º 17
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");
		}
		public void TestImportMembersMapping()
		{
			Type type = typeof (SimpleClass);
			SoapAttributes attrs = new SoapAttributes ();
			SoapAttributeOverrides overrides = new SoapAttributeOverrides ();
			overrides.Add (typeof (SimpleClass), attrs);

			XmlReflectionMember[] members = new XmlReflectionMember[0];
			XmlMembersMapping mm;
			try
			{
				mm = MembersMap(type, overrides, members, true, true);
				Assert.Fail("Should not be able to fetch an empty XmlMembersMapping");
			}
			catch (Exception)
			{
			}
			
			XmlReflectionMember rm = new XmlReflectionMember();
			rm.IsReturnValue = false;
			rm.MemberName = "something";
			rm.MemberType = typeof(string);
			members = new XmlReflectionMember[1];
			members[0] = rm;

			mm = MembersMap(type, overrides, members, false, false);

			Equals(mm.Count, 1);

			XmlMemberMapping smm = mm[0];
			Assert.IsFalse (smm.Any, "#1");
			Assert.AreEqual ("something", smm.ElementName, "#2");
			Assert.AreEqual ("something", smm.MemberName, "#3");
			Assert.IsNull (smm.Namespace, "#4");
			Assert.AreEqual ("System.String", smm.TypeFullName, "#5");
			Assert.AreEqual ("string", smm.TypeName, "#6");
			Assert.AreEqual (XmlSchemaNamespace, smm.TypeNamespace, "#7");

			
			rm = new XmlReflectionMember();
			rm.IsReturnValue = false;
			rm.MemberName = "nothing";
			rm.MemberType = typeof(string);
			members = new XmlReflectionMember[1];
			members[0] = rm;

			mm = MembersMap(type, overrides, members, false, false);
			Assert.AreEqual (1 , mm.Count, "#8");
		}
		public void TypeMapping_InvalidDefault ()
		{
			SoapAttributes attrs = new SoapAttributes (typeof (Field_Encoded).GetMember ("Modifiers")[0]);
			attrs.SoapDefaultValue = 2; // not a defined enum value
			SoapAttributeOverrides overrides = new SoapAttributeOverrides ();
			overrides.Add (typeof (Field_Encoded), "Modifiers", attrs);

			try {
				Map (typeof (Field_Encoded), overrides);
				Assert.Fail ("#A1");
			} catch (InvalidOperationException ex) {
				// Enum System.Int32 cannot be converted to MonoTests.System.Xml.TestClasses.MapModifiers
				Assert.IsNotNull (ex.Message, "#A2");
				Assert.IsTrue (ex.Message.IndexOf (typeof (int).FullName) != -1, "#A3");
				Assert.IsTrue (ex.Message.IndexOf (typeof (MapModifiers).FullName) != -1, "#A4");
				Assert.IsNull (ex.InnerException, "#A5");
			}

			attrs.SoapDefaultValue = "2"; // not of the same type as the underlying enum type (System.Int32)

			try {
				Map (typeof (Field_Encoded), overrides);
				Assert.Fail ("#B1");
			} catch (InvalidOperationException ex) {
				// Enum System.String cannot be converted to MonoTests.System.Xml.TestClasses.MapModifiers
				Assert.IsNotNull (ex.Message, "#B2");
				Assert.IsTrue (ex.Message.IndexOf (typeof (string).FullName) != -1, "#B3");
				Assert.IsTrue (ex.Message.IndexOf (typeof (MapModifiers).FullName) != -1, "#B4");
				Assert.IsNull (ex.InnerException, "#B5");
			}

			attrs.SoapDefaultValue = EnumDefaultValueNF.e2; // other enum type

			try {
				Map (typeof (Field_Encoded), overrides);
				Assert.Fail ("#C1");
			} catch (InvalidOperationException ex) {
				// Enum MonoTests.System.Xml.TestClasses.EnumDefaultValueNF cannot be converted to MonoTests.System.Xml.TestClasses.MapModifiers
				Assert.IsNotNull (ex.Message, "#C2");
				Assert.IsTrue (ex.Message.IndexOf (typeof (EnumDefaultValueNF).FullName) != -1, "#C3");
				Assert.IsTrue (ex.Message.IndexOf (typeof (MapModifiers).FullName) != -1, "#C4");
				Assert.IsNull (ex.InnerException, "#C5");
			}

			attrs.SoapDefaultValue = (MapModifiers) 20; // non-existing enum value

			try {
				Map (typeof (Field_Encoded), overrides);
				Assert.Fail ("#D1");
			} catch (InvalidOperationException ex) {
				// Value '20' cannot be converted to MonoTests.System.Xml.TestClasses.MapModifiers
				Assert.IsNotNull (ex.Message, "#D2");
				Assert.IsTrue (ex.Message.IndexOf ("'20'") != -1, "#D3");
				Assert.IsTrue (ex.Message.IndexOf (typeof (MapModifiers).FullName) != -1, "#D4");
				Assert.IsNull (ex.InnerException, "#D5");
			}
		}
		[Category ("NotDotNet")] // wrong error message is reported in .NET 1.1
#endif
		public void TypeMapping_Attribute_ComplexType ()
		{
			SoapAttributes attrs = new SoapAttributes (typeof (Field_Encoded).GetMember ("Names")[0]);
			attrs.SoapAttribute = new SoapAttributeAttribute (); // SoapAttribute cannot be used to encode complex types
			SoapAttributeOverrides overrides = new SoapAttributeOverrides ();
			overrides.Add (typeof (Field_Encoded), "Names", attrs);

			try {
				Map (typeof (Field_Encoded), overrides);
				Assert.Fail ("#A1");
			} catch (InvalidOperationException ex) {
				// Cannot serialize member 'Names' of type System.String[].
				// SoapAttribute cannot be used to encode complex types.
				Assert.IsNotNull (ex.Message, "#A2");
				Assert.IsTrue (ex.Message.IndexOf (typeof (string[]).FullName) != -1, "#A3");
				Assert.IsTrue (ex.Message.IndexOf ("SoapAttribute") != -1, "#A4");
				Assert.IsNull (ex.InnerException, "#A5");
			}
		}
 /// <include file='doc\SoapReflectionImporter.uex' path='docs/doc[@for="SoapReflectionImporter.SoapReflectionImporter2"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 public SoapReflectionImporter(SoapAttributeOverrides attributeOverrides) : this(attributeOverrides, null) {
 }
Exemplo n.º 22
0
		private void SerializeEncoded (object o, SoapAttributeOverrides ao, string defaultNamespace)
		{
			XmlTypeMapping mapping = CreateSoapMapping (o.GetType (), ao, defaultNamespace);
			SetUpWriter ();
			xs = new XmlSerializer (mapping);
			xs.Serialize (xtw, o);
		}
Exemplo n.º 23
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");
		}