当前位置: 首页>>代码示例>>C#>>正文


C# XmlReflectionImporter.ImportMembersMapping方法代码示例

本文整理汇总了C#中System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReflectionImporter.ImportMembersMapping方法的具体用法?C# XmlReflectionImporter.ImportMembersMapping怎么用?C# XmlReflectionImporter.ImportMembersMapping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.Serialization.XmlReflectionImporter的用法示例。


在下文中一共展示了XmlReflectionImporter.ImportMembersMapping方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExportXmlSerializable_NestedClassMapping

		public void ExportXmlSerializable_NestedClassMapping () {

			XmlSchemas schemas = new XmlSchemas ();

			XmlReflectionMember xmlReflectionMember = new XmlReflectionMember ();
			XmlSchemaExporter xmlSchemaExporter = new XmlSchemaExporter (schemas);
			XmlReflectionImporter xmlReflectionImporter = new XmlReflectionImporter ();

			//Export mapping for DataSet1 class.
			xmlReflectionMember.MemberType = typeof (DataSet1);
			XmlMembersMapping xmlMembersMapping = xmlReflectionImporter.ImportMembersMapping ("DataSet1Response", "ResponseNamespace",
				new XmlReflectionMember [] { xmlReflectionMember }, true);

			xmlSchemaExporter.ExportMembersMapping (xmlMembersMapping);

			//Export mapping for nested of DataSet1 class.
			xmlReflectionMember.MemberType = typeof (DataSet1.DataTable1DataTable);
			xmlMembersMapping = xmlReflectionImporter.ImportMembersMapping ("DataTable1DataTableResponse", "ResponseNamespace",
				new XmlReflectionMember [] { xmlReflectionMember }, true);

			xmlSchemaExporter.ExportMembersMapping (xmlMembersMapping);

		}
开发者ID:Profit0004,项目名称:mono,代码行数:23,代码来源:XmlExportOfTypedDataSetTest.cs

示例2: SoapMethodStubInfo

		//
		// Constructor
		//
		public SoapMethodStubInfo (TypeStubInfo typeStub, LogicalMethodInfo source, object kind, XmlReflectionImporter xmlImporter, SoapReflectionImporter soapImporter)
		: base (typeStub, source)
		{
			SoapTypeStubInfo parent = (SoapTypeStubInfo) typeStub;
			XmlElementAttribute optional_ns = null;

			if (kind == null) {
				Use = parent.LogicalType.BindingUse;
				RequestName = "";
				RequestNamespace = "";
				ResponseName = "";
				ResponseNamespace = "";
				ParameterStyle = parent.ParameterStyle;
				SoapBindingStyle = parent.SoapBindingStyle;
				OneWay = false;
// disabled (see bug #332150)
//#if NET_2_0
//				if (parent.Type != source.DeclaringType)
//					Binding = source.DeclaringType.Name + parent.ProtocolName;
//#endif
			}
			else if (kind is SoapDocumentMethodAttribute){
				SoapDocumentMethodAttribute dma = (SoapDocumentMethodAttribute) kind;
				
				Use = dma.Use;
				if (Use == SoapBindingUse.Default) {
					if (parent.SoapBindingStyle == SoapBindingStyle.Document)
						Use = parent.LogicalType.BindingUse;
					else
						Use = SoapBindingUse.Literal;
				}
				
				Action = dma.Action;
				Binding = dma.Binding;
				RequestName = dma.RequestElementName;
				RequestNamespace = dma.RequestNamespace;
				ResponseName = dma.ResponseElementName;
				ResponseNamespace = dma.ResponseNamespace;
				ParameterStyle = dma.ParameterStyle;
				if (ParameterStyle == SoapParameterStyle.Default)
					ParameterStyle = parent.ParameterStyle;
				OneWay = dma.OneWay;
				SoapBindingStyle = SoapBindingStyle.Document;
			} else {
				SoapRpcMethodAttribute rma = (SoapRpcMethodAttribute) kind;
				Use = SoapBindingUse.Encoded;	// RPC always use encoded

				Action = rma.Action;
				if (Action != null && Action.Length == 0)
					Action = null;
				Binding = rma.Binding;
				
				// When using RPC, MS.NET seems to ignore RequestElementName and
				// MessageName, and it always uses the method name
				RequestName = source.Name;
				ResponseName = source.Name + "Response";
//				RequestName = rma.RequestElementName;
//				ResponseName = rma.ResponseElementName;
				RequestNamespace = rma.RequestNamespace;
				ResponseNamespace = rma.ResponseNamespace;
				ParameterStyle = SoapParameterStyle.Wrapped;
				OneWay = rma.OneWay;
				SoapBindingStyle = SoapBindingStyle.Rpc;

				// For RPC calls, make all arguments be part of the empty namespace
				optional_ns = new XmlElementAttribute ();
				optional_ns.Namespace = "";
			}

			if (OneWay){
				if (source.ReturnType != typeof (void))
					throw new Exception ("OneWay methods should not have a return value.");
				if (source.OutParameters.Length != 0)
					throw new Exception ("OneWay methods should not have out/ref parameters.");
			}
			
			BindingInfo binfo = parent.GetBinding (Binding);
			if (binfo == null) throw new InvalidOperationException ("Type '" + parent.Type + "' is missing WebServiceBinding attribute that defines a binding named '" + Binding + "'.");
			
			string serviceNamespace = binfo.Namespace;
				
			if (RequestNamespace == "") RequestNamespace = parent.LogicalType.GetWebServiceNamespace (serviceNamespace, Use);
			if (ResponseNamespace == "") ResponseNamespace = parent.LogicalType.GetWebServiceNamespace (serviceNamespace, Use);
			if (RequestName == "") RequestName = Name;
			if (ResponseName == "")	ResponseName = Name + "Response";
			if (Action == null)
				Action = serviceNamespace.EndsWith("/") ? (serviceNamespace + Name) : (serviceNamespace + "/" + Name);
			
			bool hasWrappingElem = (ParameterStyle == SoapParameterStyle.Wrapped);
			bool writeAccessors = (SoapBindingStyle == SoapBindingStyle.Rpc);
			
			XmlReflectionMember [] in_members = BuildRequestReflectionMembers (optional_ns);
			XmlReflectionMember [] out_members = BuildResponseReflectionMembers (optional_ns);

			if (Use == SoapBindingUse.Literal) {
				xmlImporter.IncludeTypes (source.CustomAttributeProvider);
				InputMembersMapping = xmlImporter.ImportMembersMapping (RequestName, RequestNamespace, in_members, hasWrappingElem);
//.........这里部分代码省略.........
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:101,代码来源:Methods.cs

示例3: GetSerializer

		XmlSerializer GetSerializer (MessageBodyDescription desc)
		{
			if (bodySerializers.ContainsKey (desc))
				return bodySerializers [desc];

			int count = desc.Parts.Count + (HasReturnValue (desc) ? 1 : 0);
			XmlReflectionMember [] members = new XmlReflectionMember [count];

			int ind = 0;
			if (HasReturnValue (desc))
				members [ind++] = CreateReflectionMember (desc.ReturnValue, true);

			foreach (MessagePartDescription partDesc in desc.Parts)
				members [ind++] = CreateReflectionMember (partDesc, false);

			XmlReflectionImporter xmlImporter = new XmlReflectionImporter ();
			// Register known types into xmlImporter.
			foreach (var type in OperationKnownTypes)
				xmlImporter.IncludeType (type);
			XmlMembersMapping [] partsMapping = new XmlMembersMapping [1];
			partsMapping [0] = xmlImporter.ImportMembersMapping (desc.WrapperName, desc.WrapperNamespace, members, true);
			bodySerializers [desc] = XmlSerializer.FromMappings (partsMapping) [0];
			return bodySerializers [desc];
		}
开发者ID:nekresh,项目名称:mono,代码行数:24,代码来源:BaseMessagesFormatter.cs

示例4: ImportMembersMapping

 static XmlMembersMapping ImportMembersMapping(XmlReflectionImporter xmlImporter, SoapReflectionImporter soapImporter, bool serviceDefaultIsEncoded, bool rpc, SoapBindingUse use, SoapParameterStyle paramStyle, 
     string elementName, string elementNamespace, bool nsIsDefault, XmlReflectionMember[] members, bool validate, bool openModel, string key, bool writeAccess) {
     XmlMembersMapping mapping = null;
     if (use == SoapBindingUse.Encoded) {
         string ns = (!rpc && paramStyle != SoapParameterStyle.Bare && nsIsDefault) ? GetEncodedNamespace(elementNamespace, serviceDefaultIsEncoded) : elementNamespace;
         mapping = soapImporter.ImportMembersMapping(elementName, ns, members, rpc || paramStyle != SoapParameterStyle.Bare, rpc, validate, writeAccess ? XmlMappingAccess.Write : XmlMappingAccess.Read);
     }
     else {
         string ns = nsIsDefault ? GetLiteralNamespace(elementNamespace, serviceDefaultIsEncoded) : elementNamespace;
         mapping = xmlImporter.ImportMembersMapping(elementName, ns, members, paramStyle != SoapParameterStyle.Bare, rpc, openModel, writeAccess ? XmlMappingAccess.Write : XmlMappingAccess.Read);
     }
     if (mapping != null) {
         mapping.SetKey(key);
     }
     return mapping;
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:16,代码来源:SoapReflector.cs

示例5: MembersMap

		private XmlMembersMapping MembersMap(Type t, XmlAttributeOverrides overrides, 
			XmlReflectionMember [] members, bool inContainer)
		{
			XmlReflectionImporter ri = new XmlReflectionImporter(overrides);
			XmlMembersMapping mm = ri.ImportMembersMapping(null, null, members, inContainer);
			
			return mm;
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:8,代码来源:XmlReflectionImporterTests.cs

示例6: HandleOutAttributeParameters

		[Category ("NotDotNet")] // hangs on .NET 1.1
#endif
		public void HandleOutAttributeParameters ()
		{
			XmlReflectionMember m = new XmlReflectionMember ();
			m.MemberName = "hooray";
			m.MemberType = typeof (string);
			m.XmlAttributes = new XmlAttributes ();
			m.XmlAttributes.XmlAttribute = new XmlAttributeAttribute ();
			XmlReflectionImporter imp = new XmlReflectionImporter ();
			XmlMembersMapping map = imp.ImportMembersMapping (
				"elem", "urn:x", new XmlReflectionMember [] {m}, true);
			XmlSerializer ser = XmlSerializer.FromMappings (
				new XmlMapping [] {map}) [0];
			string xml = "<elem xmlns='urn:x' hooray='doh' />";
			object [] arr = ser.Deserialize (new StringReader (xml))
				as object [];
			Assert.IsNotNull (arr, "#1");
			Assert.AreEqual (1, arr.Length, "#2");
			Assert.AreEqual ("doh", arr [0], "#3");

			xml = "<elem xmlns='urn:x' hooray='doh'></elem>";
			arr = ser.Deserialize (new StringReader (xml)) as object [];
			Assert.IsNotNull (arr, "#4");
			Assert.AreEqual (1, arr.Length, "#5");
			Assert.AreEqual ("doh", arr [0], "#6");
		}
开发者ID:nobled,项目名称:mono,代码行数:27,代码来源:XmlSerializationReaderTests.cs

示例7: InvalidNullableTypeTest

		public void InvalidNullableTypeTest ()
		{
			XmlReflectionMember [] out_members = new XmlReflectionMember [1];
			XmlReflectionMember m;
			
			m = new XmlReflectionMember ();
			m.IsReturnValue = false;
			m.MemberName = "HasPermissionsForUserResultSpecified";
			m.MemberType = typeof (bool);
			m.SoapAttributes = new SoapAttributes ();
			m.XmlAttributes = new XmlAttributes ();
			m.XmlAttributes.XmlIgnore = true;
			m.XmlAttributes.XmlElements.Add (new XmlElementAttribute () { IsNullable = true });
			out_members [0] = m;
			
			XmlReflectionImporter xmlImporter = new XmlReflectionImporter ();
			
			try {
				xmlImporter.ImportMembersMapping ("HasPermissionsForUserResponse", "http://tempuri.org", out_members, true);
				Assert.Fail ("Expected InvalidOperationException");
			} catch (InvalidOperationException) {
			}
		}
开发者ID:shana,项目名称:mono,代码行数:23,代码来源:DeserializeTests.cs

示例8: SpecifiedXmlIgnoreTest

		[Test] // bug bxc 4367
		public void SpecifiedXmlIgnoreTest ()
		{
			XmlReflectionMember [] out_members = new XmlReflectionMember [2];
			XmlReflectionMember m;
			
			m = new XmlReflectionMember ();
			m.IsReturnValue = false;
			m.MemberName = "HasPermissionsForUserResult";
			m.MemberType = typeof (bool);
			m.SoapAttributes = new SoapAttributes ();
			m.XmlAttributes = new XmlAttributes ();
			out_members [0] = m;
			
			m = new XmlReflectionMember ();
			m.IsReturnValue = false;
			m.MemberName = "HasPermissionsForUserResultSpecified";
			m.MemberType = typeof (bool);
			m.SoapAttributes = new SoapAttributes ();
			m.XmlAttributes = new XmlAttributes ();
			m.XmlAttributes.XmlIgnore = true;
			out_members [1] = m;
			
			XmlReflectionImporter xmlImporter = new XmlReflectionImporter ();
			XmlMembersMapping OutputMembersMapping = xmlImporter.ImportMembersMapping ("HasPermissionsForUserResponse", "http://tempuri.org", out_members, true);
			XmlSerializer xmlSerializer = XmlSerializer.FromMappings (new XmlMapping [] { OutputMembersMapping }) [0];
			
			Assert.AreEqual (2, OutputMembersMapping.Count, "#count");
			
			string msg = @"
			<HasPermissionsForUserResponse xmlns=""http://tempuri.org/"">
				<HasPermissionsForUserResult>true</HasPermissionsForUserResult>
			</HasPermissionsForUserResponse>
			";
			
			object res = xmlSerializer.Deserialize (new StringReader (msg));
			Assert.AreEqual (typeof (object[]), res.GetType (), "type");
			Assert.AreEqual (2, ((object[]) res).Length, "length");
		}
开发者ID:shana,项目名称:mono,代码行数:39,代码来源:DeserializeTests.cs


注:本文中的System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。