本文整理汇总了C#中System.Xml.Serialization.XmlReflectionImporter.IncludeTypes方法的典型用法代码示例。如果您正苦于以下问题:C# XmlReflectionImporter.IncludeTypes方法的具体用法?C# XmlReflectionImporter.IncludeTypes怎么用?C# XmlReflectionImporter.IncludeTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Serialization.XmlReflectionImporter
的用法示例。
在下文中一共展示了XmlReflectionImporter.IncludeTypes方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetInitializer
public override object GetInitializer (LogicalMethodInfo methodInfo)
{
LogicalTypeInfo sti = TypeStubManager.GetLogicalTypeInfo (methodInfo.DeclaringType);
object[] ats = methodInfo.ReturnTypeCustomAttributeProvider.GetCustomAttributes (typeof(XmlRootAttribute), true);
XmlRootAttribute root = ats.Length > 0 ? ats[0] as XmlRootAttribute : null;
XmlReflectionImporter importer = new XmlReflectionImporter ();
importer.IncludeTypes (methodInfo.CustomAttributeProvider);
XmlTypeMapping map = importer.ImportTypeMapping (methodInfo.ReturnType, root, sti.GetWebServiceLiteralNamespace (sti.WebServiceNamespace));
return new XmlSerializer (map);
}
示例2: GetInitializers
public override object[] GetInitializers (LogicalMethodInfo[] methodInfos)
{
XmlReflectionImporter importer = new XmlReflectionImporter ();
XmlMapping[] sers = new XmlMapping [methodInfos.Length];
for (int n=0; n<sers.Length; n++)
{
LogicalMethodInfo metinfo = methodInfos[n];
if (metinfo.IsVoid)
sers[n] = null;
else
{
importer.IncludeTypes (metinfo.CustomAttributeProvider);
LogicalTypeInfo sti = TypeStubManager.GetLogicalTypeInfo (metinfo.DeclaringType);
object[] ats = methodInfos[n].ReturnTypeCustomAttributeProvider.GetCustomAttributes (typeof(XmlRootAttribute), true);
XmlRootAttribute root = ats.Length > 0 ? ats[0] as XmlRootAttribute : null;
sers[n] = importer.ImportTypeMapping (methodInfos[n].ReturnType, root, sti.GetWebServiceLiteralNamespace (sti.WebServiceNamespace));
}
}
return XmlSerializer.FromMappings (sers);
}
示例3: SoapTypeStubInfo
public SoapTypeStubInfo (LogicalTypeInfo logicalTypeInfo)
: base (logicalTypeInfo)
{
xmlImporter = new XmlReflectionImporter ();
soapImporter = new SoapReflectionImporter ();
if (typeof (SoapHttpClientProtocol).IsAssignableFrom (Type))
{
if (Bindings.Count == 0 || ((BindingInfo)Bindings[0]).WebServiceBindingAttribute == null)
throw new InvalidOperationException ("WebServiceBindingAttribute is required on proxy class '" + Type + "'.");
if (Bindings.Count > 1)
throw new InvalidOperationException ("Only one WebServiceBinding attribute may be specified on type '" + Type + "'.");
}
object [] o = Type.GetCustomAttributes (typeof (SoapDocumentServiceAttribute), false);
if (o.Length == 1){
SoapDocumentServiceAttribute a = (SoapDocumentServiceAttribute) o [0];
ParameterStyle = a.ParameterStyle;
SoapBindingStyle = SoapBindingStyle.Document;
} else {
o = Type.GetCustomAttributes (typeof (SoapRpcServiceAttribute), false);
if (o.Length == 1){
ParameterStyle = SoapParameterStyle.Wrapped;
SoapBindingStyle = SoapBindingStyle.Rpc;
} else {
ParameterStyle = SoapParameterStyle.Wrapped;
SoapBindingStyle = SoapBindingStyle.Document;
}
}
if (ParameterStyle == SoapParameterStyle.Default) ParameterStyle = SoapParameterStyle.Wrapped;
xmlImporter.IncludeTypes (Type);
soapImporter.IncludeTypes (Type);
#if MOBILE || XAMMAC_4_5
SoapExtensions = new SoapExtensionRuntimeConfig [2][];
#else
SoapExtensions = SoapExtension.GetTypeExtensions (Type);
#endif
}
示例4: 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);
//.........这里部分代码省略.........
示例5: IncludeTypes
internal static void IncludeTypes(LogicalMethodInfo method, XmlReflectionImporter importer)
{
if (method.Declaration != null)
{
importer.IncludeTypes(method.Declaration.DeclaringType);
importer.IncludeTypes(method.Declaration);
}
importer.IncludeTypes(method.DeclaringType);
importer.IncludeTypes(method.CustomAttributeProvider);
}
示例6: SoapTypeStubInfo
public SoapTypeStubInfo (LogicalTypeInfo logicalTypeInfo)
: base (logicalTypeInfo)
{
xmlImporter = new XmlReflectionImporter ();
soapImporter = new SoapReflectionImporter ();
object [] o;
o = Type.GetCustomAttributes (typeof (WebServiceBindingAttribute), false);
if (typeof (SoapHttpClientProtocol).IsAssignableFrom (Type))
{
if (o.Length == 0)
throw new InvalidOperationException ("WebServiceBindingAttribute is required on proxy class '" + Type + "'.");
if (o.Length > 1)
throw new InvalidOperationException ("Only one WebServiceBinding attribute may be specified on type '" + Type + "'.");
// Remove the default binding, it is not needed since there is always
// a binding attribute.
Bindings.Clear ();
}
foreach (WebServiceBindingAttribute at in o)
AddBinding (new BindingInfo (at, LogicalType.WebServiceNamespace));
o = Type.GetCustomAttributes (typeof (SoapDocumentServiceAttribute), false);
if (o.Length == 1){
SoapDocumentServiceAttribute a = (SoapDocumentServiceAttribute) o [0];
ParameterStyle = a.ParameterStyle;
RoutingStyle = a.RoutingStyle;
Use = a.Use;
SoapBindingStyle = SoapBindingStyle.Document;
} else {
o = Type.GetCustomAttributes (typeof (SoapRpcServiceAttribute), false);
if (o.Length == 1){
SoapRpcServiceAttribute srs = (SoapRpcServiceAttribute) o [0];
ParameterStyle = SoapParameterStyle.Wrapped;
RoutingStyle = srs.RoutingStyle;
Use = SoapBindingUse.Encoded;
SoapBindingStyle = SoapBindingStyle.Rpc;
} else {
ParameterStyle = SoapParameterStyle.Wrapped;
RoutingStyle = SoapServiceRoutingStyle.SoapAction;
Use = SoapBindingUse.Literal;
SoapBindingStyle = SoapBindingStyle.Document;
}
}
if (ParameterStyle == SoapParameterStyle.Default) ParameterStyle = SoapParameterStyle.Wrapped;
if (Use == SoapBindingUse.Default) Use = SoapBindingUse.Literal;
xmlImporter.IncludeTypes (Type);
soapImporter.IncludeTypes (Type);
SoapExtensions = SoapExtension.GetTypeExtensions (Type);
}