本文整理汇总了C#中System.Web.Services.Protocols.LogicalMethodInfo.GetCustomAttributes方法的典型用法代码示例。如果您正苦于以下问题:C# LogicalMethodInfo.GetCustomAttributes方法的具体用法?C# LogicalMethodInfo.GetCustomAttributes怎么用?C# LogicalMethodInfo.GetCustomAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Services.Protocols.LogicalMethodInfo
的用法示例。
在下文中一共展示了LogicalMethodInfo.GetCustomAttributes方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSoapMethodBinding
internal static string GetSoapMethodBinding(LogicalMethodInfo method)
{
string binding;
object[] customAttributes = method.GetCustomAttributes(typeof(SoapDocumentMethodAttribute));
if (customAttributes.Length == 0)
{
customAttributes = method.GetCustomAttributes(typeof(SoapRpcMethodAttribute));
if (customAttributes.Length == 0)
{
binding = string.Empty;
}
else
{
binding = ((SoapRpcMethodAttribute) customAttributes[0]).Binding;
}
}
else
{
binding = ((SoapDocumentMethodAttribute) customAttributes[0]).Binding;
}
if (method.Binding == null)
{
return binding;
}
if ((binding.Length > 0) && (binding != method.Binding.Name))
{
throw new InvalidOperationException(System.Web.Services.Res.GetString("WebInvalidBindingName", new object[] { binding, method.Binding.Name }));
}
return method.Binding.Name;
}
示例2: GetSoapMethodAttribute
internal static object GetSoapMethodAttribute(LogicalMethodInfo methodInfo)
{
object[] customAttributes = methodInfo.GetCustomAttributes(typeof(SoapRpcMethodAttribute));
object[] objArray2 = methodInfo.GetCustomAttributes(typeof(SoapDocumentMethodAttribute));
if (customAttributes.Length > 0)
{
if (objArray2.Length > 0)
{
throw new ArgumentException(System.Web.Services.Res.GetString("WebBothMethodAttrs"), "methodInfo");
}
return customAttributes[0];
}
if (objArray2.Length > 0)
{
return objArray2[0];
}
return null;
}
示例3: MethodStubInfo
//
// Constructor
//
public MethodStubInfo (TypeStubInfo parent, LogicalMethodInfo source)
{
TypeStub = parent;
MethodInfo = source;
object [] o = source.GetCustomAttributes (typeof (WebMethodAttribute));
if (o.Length > 0)
{
MethodAttribute = (WebMethodAttribute) o [0];
Name = MethodAttribute.MessageName;
if (Name == "") Name = source.Name;
}
else
Name = source.Name;
}
示例4: CreateMethodStubInfo
protected override MethodStubInfo CreateMethodStubInfo (TypeStubInfo parent, LogicalMethodInfo lmi, bool isClientProxy)
{
SoapMethodStubInfo res = null;
object [] ats = lmi.GetCustomAttributes (typeof (SoapDocumentMethodAttribute));
if (ats.Length == 0) ats = lmi.GetCustomAttributes (typeof (SoapRpcMethodAttribute));
if (ats.Length == 0 && isClientProxy)
return null;
else if (ats.Length == 0)
res = new SoapMethodStubInfo (parent, lmi, null, xmlImporter, soapImporter);
else
res = new SoapMethodStubInfo (parent, lmi, ats[0], xmlImporter, soapImporter);
methods_byaction [res.Action] = res;
return res;
}
示例5: SoapMethodStubInfo
//.........这里部分代码省略.........
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);
OutputMembersMapping = xmlImporter.ImportMembersMapping (ResponseName, ResponseNamespace, out_members, hasWrappingElem);
}
else {
soapImporter.IncludeTypes (source.CustomAttributeProvider);
InputMembersMapping = soapImporter.ImportMembersMapping (RequestName, RequestNamespace, in_members, hasWrappingElem, writeAccessors);
OutputMembersMapping = soapImporter.ImportMembersMapping (ResponseName, ResponseNamespace, out_members, hasWrappingElem, writeAccessors);
}
InputMembersMapping.SetKey(RequestName);
OutputMembersMapping.SetKey(ResponseName);
requestSerializerId = parent.RegisterSerializer (InputMembersMapping);
responseSerializerId = parent.RegisterSerializer (OutputMembersMapping);
object[] o = source.GetCustomAttributes (typeof (SoapHeaderAttribute));
ArrayList allHeaderList = new ArrayList (o.Length);
ArrayList inHeaderList = new ArrayList (o.Length);
ArrayList outHeaderList = new ArrayList (o.Length);
ArrayList faultHeaderList = new ArrayList ();
SoapHeaderDirection unknownHeaderDirections = (SoapHeaderDirection)0;
for (int i = 0; i < o.Length; i++) {
SoapHeaderAttribute att = (SoapHeaderAttribute) o[i];
MemberInfo[] mems = source.DeclaringType.GetMember (att.MemberName);
if (mems.Length == 0) throw new InvalidOperationException ("Member " + att.MemberName + " not found in class " + source.DeclaringType.FullName + ".");
HeaderInfo header = new HeaderInfo (mems[0], att);
allHeaderList.Add (header);
if (!header.Custom) {
if ((header.Direction & SoapHeaderDirection.In) != 0)
inHeaderList.Add (header);
if ((header.Direction & SoapHeaderDirection.Out) != 0)
outHeaderList.Add (header);
if ((header.Direction & SoapHeaderDirection.Fault) != 0)
faultHeaderList.Add (header);
} else
unknownHeaderDirections |= header.Direction;
}
Headers = (HeaderInfo[]) allHeaderList.ToArray (typeof(HeaderInfo));
if (inHeaderList.Count > 0 || (unknownHeaderDirections & SoapHeaderDirection.In) != 0) {
InHeaders = (HeaderInfo[]) inHeaderList.ToArray (typeof(HeaderInfo));
XmlReflectionMember[] members = BuildHeadersReflectionMembers (InHeaders);
if (Use == SoapBindingUse.Literal)
示例6: GetMethodExtensions
internal static SoapExtensionRuntimeConfig[] GetMethodExtensions (LogicalMethodInfo method)
{
object[] ats = method.GetCustomAttributes (typeof (SoapExtensionAttribute));
SoapExtensionRuntimeConfig[] exts = new SoapExtensionRuntimeConfig [ats.Length];
int[] priorities = new int[ats.Length];
for (int n=0; n<ats.Length; n++)
{
SoapExtensionAttribute at = (SoapExtensionAttribute) ats[n];
SoapExtensionRuntimeConfig econf = new SoapExtensionRuntimeConfig ();
econf.Type = at.ExtensionType;
priorities [n] = at.Priority;
SoapExtension ext = (SoapExtension) Activator.CreateInstance (econf.Type);
econf.InitializationInfo = ext.GetInitializer (method, at);
exts [n] = econf;
}
Array.Sort (priorities, exts);
return exts;
}
示例7: ReflectMethod
//.........这里部分代码省略.........
identifiers = new CodeIdentifiers();
}
members = new XmlReflectionMember[numOutParams];
for (int i = 0; i < outParameters.Length; i++) {
SoapParameterInfo soapParamInfo = outParameters[i];
XmlReflectionMember member = new XmlReflectionMember();
member.MemberName = soapParamInfo.parameterInfo.Name;
member.MemberType = soapParamInfo.parameterInfo.ParameterType;
if (member.MemberType.IsByRef)
member.MemberType = member.MemberType.GetElementType();
member.XmlAttributes = soapParamInfo.xmlAttributes;
member.SoapAttributes = soapParamInfo.soapAttributes;
members[count++] = member;
if (identifiers != null)
identifiers.Add(member.MemberName, null);
}
if (methodInfo.ReturnType != typeof(void)) {
XmlReflectionMember member = new XmlReflectionMember();
member.MemberName = identifiers.MakeUnique(soapMethod.name + "Result");
member.MemberType = methodInfo.ReturnType;
member.IsReturnValue = true;
member.XmlAttributes = new XmlAttributes(methodInfo.ReturnTypeCustomAttributeProvider);
member.XmlAttributes.XmlRoot = null; // Ignore XmlRoot attribute used by get/post
member.SoapAttributes = new SoapAttributes(methodInfo.ReturnTypeCustomAttributeProvider);
members[0] = member;
}
soapMethod.responseMappings = ImportMembersMapping(xmlImporter, soapImporter, serviceDefaultIsEncoded, soapMethod.rpc, soapMethod.use, soapMethod.paramStyle, responseElementName, responseNamespace, methodAttribute.responseNs == null, members, false, false, methodId + ":Response", !client);
}
SoapExtensionAttribute[] extensionAttributes = (SoapExtensionAttribute[])methodInfo.GetCustomAttributes(typeof(SoapExtensionAttribute));
soapMethod.extensions = new SoapReflectedExtension[extensionAttributes.Length];
for (int i = 0; i < extensionAttributes.Length; i++)
soapMethod.extensions[i] = new SoapReflectedExtension(extensionAttributes[i].ExtensionType, extensionAttributes[i]);
Array.Sort(soapMethod.extensions);
SoapHeaderAttribute[] headerAttributes = (SoapHeaderAttribute[])methodInfo.GetCustomAttributes(typeof(SoapHeaderAttribute));
Array.Sort(headerAttributes, new SoapHeaderAttributeComparer());
Hashtable headerTypes = new Hashtable();
soapMethod.headers = new SoapReflectedHeader[headerAttributes.Length];
int front = 0;
int back = soapMethod.headers.Length;
ArrayList inHeaders = new ArrayList();
ArrayList outHeaders = new ArrayList();
for (int i = 0; i < soapMethod.headers.Length; i++) {
SoapHeaderAttribute headerAttribute = headerAttributes[i];
SoapReflectedHeader soapHeader = new SoapReflectedHeader();
Type declaringType = methodInfo.DeclaringType;
if ((soapHeader.memberInfo = declaringType.GetField(headerAttribute.MemberName)) != null) {
soapHeader.headerType = ((FieldInfo)soapHeader.memberInfo).FieldType;
}
else if ((soapHeader.memberInfo = declaringType.GetProperty(headerAttribute.MemberName)) != null) {
soapHeader.headerType = ((PropertyInfo)soapHeader.memberInfo).PropertyType;
}
else {
throw HeaderException(headerAttribute.MemberName, methodInfo.DeclaringType, Res.WebHeaderMissing);
}
if (soapHeader.headerType.IsArray) {
soapHeader.headerType = soapHeader.headerType.GetElementType();
soapHeader.repeats = true;
if (soapHeader.headerType != typeof(SoapUnknownHeader) && soapHeader.headerType != typeof(SoapHeader))
throw HeaderException(headerAttribute.MemberName, methodInfo.DeclaringType, Res.WebHeaderType);
}
示例8: GetSoapMethodBinding
internal static string GetSoapMethodBinding(LogicalMethodInfo method) {
string binding;
object[] attrs = method.GetCustomAttributes(typeof(SoapDocumentMethodAttribute));
if (attrs.Length == 0) {
attrs = method.GetCustomAttributes(typeof(SoapRpcMethodAttribute));
if (attrs.Length == 0)
binding = string.Empty;
else
binding = ((SoapRpcMethodAttribute)attrs[0]).Binding;
}
else
binding = ((SoapDocumentMethodAttribute)attrs[0]).Binding;
if (method.Binding != null) {
if (binding.Length > 0 && binding != method.Binding.Name) {
throw new InvalidOperationException(Res.GetString(Res.WebInvalidBindingName, binding, method.Binding.Name));
}
return method.Binding.Name;
}
return binding;
}
示例9: GetSoapMethodAttribute
internal static object GetSoapMethodAttribute(LogicalMethodInfo methodInfo) {
object[] rpcMethodAttributes = methodInfo.GetCustomAttributes(typeof(SoapRpcMethodAttribute));
object[] docMethodAttributes = methodInfo.GetCustomAttributes(typeof(SoapDocumentMethodAttribute));
if (rpcMethodAttributes.Length > 0) {
if (docMethodAttributes.Length > 0) throw new ArgumentException(Res.GetString(Res.WebBothMethodAttrs), "methodInfo");
return rpcMethodAttributes[0];
}
else if (docMethodAttributes.Length > 0)
return docMethodAttributes[0];
else
return null;
}
示例10: ReflectMethod
//.........这里部分代码省略.........
for (int m = 0; m < infoArray2.Length; m++)
{
SoapParameterInfo info2 = infoArray2[m];
XmlReflectionMember member2 = new XmlReflectionMember {
MemberName = info2.parameterInfo.Name,
MemberType = info2.parameterInfo.ParameterType
};
if (member2.MemberType.IsByRef)
{
member2.MemberType = member2.MemberType.GetElementType();
}
member2.XmlAttributes = info2.xmlAttributes;
member2.SoapAttributes = info2.soapAttributes;
members[num3++] = member2;
if (identifiers != null)
{
identifiers.Add(member2.MemberName, null);
}
}
if (methodInfo.ReturnType != typeof(void))
{
XmlReflectionMember member3 = new XmlReflectionMember {
MemberName = identifiers.MakeUnique(method.name + "Result"),
MemberType = methodInfo.ReturnType,
IsReturnValue = true,
XmlAttributes = new XmlAttributes(methodInfo.ReturnTypeCustomAttributeProvider)
};
member3.XmlAttributes.XmlRoot = null;
member3.SoapAttributes = new SoapAttributes(methodInfo.ReturnTypeCustomAttributeProvider);
members[0] = member3;
}
method.responseMappings = ImportMembersMapping(xmlImporter, soapImporter, serviceDefaultIsEncoded, method.rpc, method.use, method.paramStyle, str4, responseNs, attribute.responseNs == null, members, false, false, key + ":Response", !client);
}
SoapExtensionAttribute[] customAttributes = (SoapExtensionAttribute[]) methodInfo.GetCustomAttributes(typeof(SoapExtensionAttribute));
method.extensions = new SoapReflectedExtension[customAttributes.Length];
for (int j = 0; j < customAttributes.Length; j++)
{
method.extensions[j] = new SoapReflectedExtension(customAttributes[j].ExtensionType, customAttributes[j]);
}
Array.Sort<SoapReflectedExtension>(method.extensions);
SoapHeaderAttribute[] array = (SoapHeaderAttribute[]) methodInfo.GetCustomAttributes(typeof(SoapHeaderAttribute));
Array.Sort(array, new SoapHeaderAttributeComparer());
Hashtable hashtable = new Hashtable();
method.headers = new SoapReflectedHeader[array.Length];
int num6 = 0;
int length = method.headers.Length;
ArrayList list = new ArrayList();
ArrayList list2 = new ArrayList();
for (int k = 0; k < method.headers.Length; k++)
{
SoapHeaderAttribute attribute7 = array[k];
SoapReflectedHeader header = new SoapReflectedHeader();
Type declaringType = methodInfo.DeclaringType;
header.memberInfo = declaringType.GetField(attribute7.MemberName);
if (header.memberInfo != null)
{
header.headerType = ((FieldInfo) header.memberInfo).FieldType;
}
else
{
header.memberInfo = declaringType.GetProperty(attribute7.MemberName);
if (header.memberInfo == null)
{
throw HeaderException(attribute7.MemberName, methodInfo.DeclaringType, "WebHeaderMissing");
}
header.headerType = ((PropertyInfo) header.memberInfo).PropertyType;