public static GetCachedSoapAttribute ( Object reflectionObject ) : SoapAttribute | ||
reflectionObject | Object | |
Результат | SoapAttribute |
} // GetXmlElementForInteropType /// <include file='doc\Soap.uex' path='docs/doc[@for="SoapServices.GetXmlTypeForInteropType"]/*' /> public static bool GetXmlTypeForInteropType(Type type, out String xmlType, out String xmlTypeNamespace) { // check table first XmlEntry entry = (XmlEntry)_interopTypeToXmlType[type]; if (entry != null) { xmlType = entry.Name; xmlTypeNamespace = entry.Namespace; return(true); } // check soap attribute SoapTypeAttribute attr = (SoapTypeAttribute) InternalRemotingServices.GetCachedSoapAttribute(type); if (attr.IsInteropXmlType()) { xmlType = attr.XmlTypeName; xmlTypeNamespace = attr.XmlTypeNamespace; return(true); } else { xmlType = null; xmlTypeNamespace = null; return(false); } } // GetXmlTypeForInteropType
} // GetXmlNamespaceForMethodCall /// <include file='doc\Soap.uex' path='docs/doc[@for="SoapServices.GetXmlNamespaceForMethodResponse"]/*' /> public static String GetXmlNamespaceForMethodResponse(MethodBase mb) { SoapMethodAttribute attr = (SoapMethodAttribute) InternalRemotingServices.GetCachedSoapAttribute(mb); return(attr.ResponseXmlNamespace); } // GetXmlNamespaceForMethodResponse
// Get XML type information for a type. public static bool GetXmlTypeForInteropType (Type type, out String xmlType, out String xmlTypeNamespace) { // Look in the registered type table first. lock (typeof(SoapServices)) { if (typeToXmlType != null) { String key = (String)(typeToXmlType[type]); if (key != null) { XmlKeyExpand(key, out xmlType, out xmlTypeNamespace); return(true); } } } // Check the attribute on the type. SoapTypeAttribute tattr = (SoapTypeAttribute) InternalRemotingServices.GetCachedSoapAttribute(type); if (tattr.xmlTypeWasSet) { xmlType = tattr.XmlTypeName; xmlTypeNamespace = tattr.XmlTypeNamespace; return(true); } // We were unable to determine the XML element information. xmlType = null; xmlTypeNamespace = null; return(false); }
public static void PreLoad(Type type) { // Register soap actions for the methods in the type. foreach (MethodInfo method in type.GetMethods()) { RegisterSoapActionForMethodBase(method); } // Register XML tags for the type, if specified. SoapTypeAttribute tattr = (SoapTypeAttribute) InternalRemotingServices.GetCachedSoapAttribute(type); if (tattr.xmlElementWasSet) { RegisterInteropXmlElement (tattr.XmlElementName, tattr.XmlNamespace, type); } if (tattr.xmlTypeWasSet) { RegisterInteropXmlType (tattr.XmlTypeName, tattr.XmlTypeNamespace, type); } // Load and register the field mapping information. lock (typeof(SoapServices)) { if (fields == null) { fields = new Hashtable(); } TypeFieldInfo typeInfo = new TypeFieldInfo(); foreach (FieldInfo field in type.GetFields()) { SoapFieldAttribute fattr = (SoapFieldAttribute) InternalRemotingServices.GetCachedSoapAttribute (field); if (fattr.IsInteropXmlElement()) { if (fattr.UseAttribute) { typeInfo.StoreAttribute (XmlKey(fattr.XmlElementName, fattr.XmlNamespace), field.Name, field.FieldType); } else { typeInfo.StoreElement (XmlKey(fattr.XmlElementName, fattr.XmlNamespace), field.Name, field.FieldType); } } } if (typeInfo.IsPopulated) { fields[type] = typeInfo; } } }
public static bool IsSoapActionValidForMethodBase(string soapAction, MethodBase mb) { bool flag; RuntimeModule runtimeModule; if (mb == null) { throw new ArgumentNullException("mb"); } if ((soapAction[0] == '"') && (soapAction[soapAction.Length - 1] == '"')) { soapAction = soapAction.Substring(1, soapAction.Length - 2); } SoapMethodAttribute cachedSoapAttribute = (SoapMethodAttribute)InternalRemotingServices.GetCachedSoapAttribute(mb); if (string.CompareOrdinal(cachedSoapAttribute.SoapAction, soapAction) == 0) { return(true); } string strA = (string)_methodBaseToSoapAction[mb]; if ((strA != null) && (string.CompareOrdinal(strA, soapAction) == 0)) { return(true); } string[] strArray = soapAction.Split(new char[] { '#' }); if (strArray.Length != 2) { return(false); } string typeNameForSoapActionNamespace = XmlNamespaceEncoder.GetTypeNameForSoapActionNamespace(strArray[0], out flag); if (typeNameForSoapActionNamespace == null) { return(false); } string str3 = strArray[1]; RuntimeMethodInfo info = mb as RuntimeMethodInfo; RuntimeConstructorInfo info2 = mb as RuntimeConstructorInfo; if (info != null) { runtimeModule = info.GetRuntimeModule(); } else { if (info2 == null) { throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeReflectionObject")); } runtimeModule = info2.GetRuntimeModule(); } string fullName = mb.DeclaringType.FullName; if (flag) { fullName = fullName + ", " + runtimeModule.GetRuntimeAssembly().GetSimpleName(); } return(fullName.Equals(typeNameForSoapActionNamespace) && mb.Name.Equals(str3)); }
public static void RegisterSoapActionForMethodBase(MethodBase mb) { SoapMethodAttribute soapMethodAttribute = (SoapMethodAttribute)InternalRemotingServices.GetCachedSoapAttribute(mb); if (soapMethodAttribute.SoapActionExplicitySet) { SoapServices.RegisterSoapActionForMethodBase(mb, soapMethodAttribute.SoapAction); } }
} // RegisterInteropXmlType /// <include file='doc\Soap.uex' path='docs/doc[@for="SoapServices.PreLoad"]/*' /> public static void PreLoad(Type type) { // register soap action values MethodInfo[] methods = type.GetMethods(); foreach (MethodInfo mi in methods) { // This will only add an entry to the table if SoapAction was explicitly set // on the SoapMethodAttribute. RegisterSoapActionForMethodBase(mi); } // register interop xml elements and types if specified SoapTypeAttribute attr = (SoapTypeAttribute) InternalRemotingServices.GetCachedSoapAttribute(type); if (attr.IsInteropXmlElement()) { RegisterInteropXmlElement(attr.XmlElementName, attr.XmlNamespace, type); } if (attr.IsInteropXmlType()) { RegisterInteropXmlType(attr.XmlTypeName, attr.XmlTypeNamespace, type); } // construct field maps for mapping xml elements and attributes back to // the correct type int mapCount = 0; XmlToFieldTypeMap map = new XmlToFieldTypeMap(); foreach (FieldInfo field in type.GetFields()) { SoapFieldAttribute fieldAttr = (SoapFieldAttribute) InternalRemotingServices.GetCachedSoapAttribute(field); if (fieldAttr.IsInteropXmlElement()) { String xmlName = fieldAttr.XmlElementName; String xmlNamespace = fieldAttr.XmlNamespace; if (fieldAttr.UseAttribute) { map.AddXmlAttribute(field.FieldType, field.Name, xmlName, xmlNamespace); } else { map.AddXmlElement(field.FieldType, field.Name, xmlName, xmlNamespace); } mapCount++; } } // foreach field // add field map if there is more than one entry if (mapCount > 0) { _xmlToFieldTypeMap[type] = map; } } // PreLoad
public static string GetSoapActionFromMethodBase(MethodBase mb) { string soapAction = (string)_methodBaseToSoapAction[mb]; if (soapAction == null) { SoapMethodAttribute cachedSoapAttribute = (SoapMethodAttribute)InternalRemotingServices.GetCachedSoapAttribute(mb); soapAction = cachedSoapAttribute.SoapAction; } return(soapAction); }
public static string GetSoapActionFromMethodBase(MethodBase mb) { string text = (string)SoapServices._methodBaseToSoapAction[mb]; if (text == null) { SoapMethodAttribute soapMethodAttribute = (SoapMethodAttribute)InternalRemotingServices.GetCachedSoapAttribute(mb); text = soapMethodAttribute.SoapAction; } return(text); }
public static void PreLoad(Type type) { string name, namspace; TypeInfo tf = _typeInfos [type] as TypeInfo; if (tf != null) { return; } if (GetXmlTypeForInteropType(type, out name, out namspace)) { RegisterInteropXmlType(name, namspace, type); } if (GetXmlElementForInteropType(type, out name, out namspace)) { RegisterInteropXmlElement(name, namspace, type); } lock (_typeInfos.SyncRoot) { tf = new TypeInfo(); FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo field in fields) { SoapFieldAttribute att = (SoapFieldAttribute)InternalRemotingServices.GetCachedSoapAttribute(field); if (!att.IsInteropXmlElement()) { continue; } string key = GetNameKey(att.XmlElementName, att.XmlNamespace); if (att.UseAttribute) { if (tf.Attributes == null) { tf.Attributes = new Hashtable(); } tf.Attributes [key] = field; } else { if (tf.Elements == null) { tf.Elements = new Hashtable(); } tf.Elements [key] = field; } } _typeInfos [type] = tf; } }
// Register a SOAP action for a method. public static void RegisterSoapActionForMethodBase(MethodBase mb) { // Fetch the action from the method base. SoapMethodAttribute mattr; mattr = (SoapMethodAttribute) InternalRemotingServices.GetCachedSoapAttribute(mb); if (mattr.soapActionWasSet) { RegisterSoapActionForMethodBase(mb, mattr.SoapAction); } }
/// <summary>Preloads the given <see cref="T:System.Type" /> based on values set in a <see cref="T:System.Runtime.Remoting.Metadata.SoapTypeAttribute" /> on the type.</summary> /// <param name="type">The <see cref="T:System.Type" /> to preload. </param> /// <exception cref="T:System.Security.SecurityException">The immediate caller does not have infrastructure permission. </exception> /// <PermissionSet> /// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" /> /// </PermissionSet> public static void PreLoad(Type type) { SoapServices.TypeInfo typeInfo = SoapServices._typeInfos[type] as SoapServices.TypeInfo; if (typeInfo != null) { return; } string text; string text2; if (SoapServices.GetXmlTypeForInteropType(type, out text, out text2)) { SoapServices.RegisterInteropXmlType(text, text2, type); } if (SoapServices.GetXmlElementForInteropType(type, out text, out text2)) { SoapServices.RegisterInteropXmlElement(text, text2, type); } object syncRoot = SoapServices._typeInfos.SyncRoot; lock (syncRoot) { typeInfo = new SoapServices.TypeInfo(); FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { SoapFieldAttribute soapFieldAttribute = (SoapFieldAttribute)InternalRemotingServices.GetCachedSoapAttribute(fieldInfo); if (soapFieldAttribute.IsInteropXmlElement()) { string nameKey = SoapServices.GetNameKey(soapFieldAttribute.XmlElementName, soapFieldAttribute.XmlNamespace); if (soapFieldAttribute.UseAttribute) { if (typeInfo.Attributes == null) { typeInfo.Attributes = new Hashtable(); } typeInfo.Attributes[nameKey] = fieldInfo; } else { if (typeInfo.Elements == null) { typeInfo.Elements = new Hashtable(); } typeInfo.Elements[nameKey] = fieldInfo; } } } SoapServices._typeInfos[type] = typeInfo; } }
public static void PreLoad(Type type) { if (type == null) { throw new ArgumentNullException("type"); } if (!(type is RuntimeType)) { throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType")); } MethodInfo[] methods = type.GetMethods(); foreach (MethodInfo mb in methods) { SoapServices.RegisterSoapActionForMethodBase(mb); } SoapTypeAttribute soapTypeAttribute = (SoapTypeAttribute)InternalRemotingServices.GetCachedSoapAttribute(type); if (soapTypeAttribute.IsInteropXmlElement()) { SoapServices.RegisterInteropXmlElement(soapTypeAttribute.XmlElementName, soapTypeAttribute.XmlNamespace, type); } if (soapTypeAttribute.IsInteropXmlType()) { SoapServices.RegisterInteropXmlType(soapTypeAttribute.XmlTypeName, soapTypeAttribute.XmlTypeNamespace, type); } int num = 0; SoapServices.XmlToFieldTypeMap xmlToFieldTypeMap = new SoapServices.XmlToFieldTypeMap(); foreach (FieldInfo fieldInfo in type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) { SoapFieldAttribute soapFieldAttribute = (SoapFieldAttribute)InternalRemotingServices.GetCachedSoapAttribute(fieldInfo); if (soapFieldAttribute.IsInteropXmlElement()) { string xmlElementName = soapFieldAttribute.XmlElementName; string xmlNamespace = soapFieldAttribute.XmlNamespace; if (soapFieldAttribute.UseAttribute) { xmlToFieldTypeMap.AddXmlAttribute(fieldInfo.FieldType, fieldInfo.Name, xmlElementName, xmlNamespace); } else { xmlToFieldTypeMap.AddXmlElement(fieldInfo.FieldType, fieldInfo.Name, xmlElementName, xmlNamespace); } num++; } } if (num > 0) { SoapServices._xmlToFieldTypeMap[type] = xmlToFieldTypeMap; } }
public static void PreLoad(Type type) { if (type == null) { throw new ArgumentNullException("type"); } if (!(type is RuntimeType)) { throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType")); } foreach (MethodInfo info in type.GetMethods()) { RegisterSoapActionForMethodBase(info); } SoapTypeAttribute cachedSoapAttribute = (SoapTypeAttribute)InternalRemotingServices.GetCachedSoapAttribute(type); if (cachedSoapAttribute.IsInteropXmlElement()) { RegisterInteropXmlElement(cachedSoapAttribute.XmlElementName, cachedSoapAttribute.XmlNamespace, type); } if (cachedSoapAttribute.IsInteropXmlType()) { RegisterInteropXmlType(cachedSoapAttribute.XmlTypeName, cachedSoapAttribute.XmlTypeNamespace, type); } int num = 0; XmlToFieldTypeMap map = new XmlToFieldTypeMap(); foreach (FieldInfo info2 in type.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)) { SoapFieldAttribute attribute2 = (SoapFieldAttribute)InternalRemotingServices.GetCachedSoapAttribute(info2); if (attribute2.IsInteropXmlElement()) { string xmlElementName = attribute2.XmlElementName; string xmlNamespace = attribute2.XmlNamespace; if (attribute2.UseAttribute) { map.AddXmlAttribute(info2.FieldType, info2.Name, xmlElementName, xmlNamespace); } else { map.AddXmlElement(info2.FieldType, info2.Name, xmlElementName, xmlNamespace); } num++; } } if (num > 0) { _xmlToFieldTypeMap[type] = map; } }
/// <summary>Returns XML type information that should be used when serializing the given <see cref="T:System.Type" />.</summary> /// <returns>true if the requested values have been set flagged with <see cref="T:System.Runtime.Remoting.Metadata.SoapTypeAttribute" />; otherwise, false.</returns> /// <param name="type">The object <see cref="T:System.Type" /> for which the XML element and namespace names were requested. </param> /// <param name="xmlType">The XML type of the specified object <see cref="T:System.Type" />. </param> /// <param name="xmlTypeNamespace">The XML type namespace of the specified object <see cref="T:System.Type" />. </param> /// <exception cref="T:System.Security.SecurityException">The immediate caller does not have infrastructure permission. </exception> /// <PermissionSet> /// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" /> /// </PermissionSet> public static bool GetXmlTypeForInteropType(Type type, out string xmlType, out string xmlTypeNamespace) { SoapTypeAttribute soapTypeAttribute = (SoapTypeAttribute)InternalRemotingServices.GetCachedSoapAttribute(type); if (!soapTypeAttribute.IsInteropXmlType) { xmlType = null; xmlTypeNamespace = null; return(false); } xmlType = soapTypeAttribute.XmlTypeName; xmlTypeNamespace = soapTypeAttribute.XmlTypeNamespace; return(true); }
static string InternalGetSoapAction(MethodBase mb) { lock (_soapActions.SyncRoot) { string action = (string)_soapActions [mb]; if (action == null) { SoapMethodAttribute att = (SoapMethodAttribute)InternalRemotingServices.GetCachedSoapAttribute(mb); action = att.SoapAction; _soapActions [mb] = action; _soapActionsMethods [action] = mb; } return(action); } }
public static bool GetXmlElementForInteropType(Type type, out string xmlElement, out string xmlNamespace) { SoapTypeAttribute att = (SoapTypeAttribute)InternalRemotingServices.GetCachedSoapAttribute(type); if (!att.IsInteropXmlElement) { xmlElement = null; xmlNamespace = null; return(false); } xmlElement = att.XmlElementName; xmlNamespace = att.XmlNamespace; return(true); }
private static string InternalGetSoapAction(MethodBase mb) { object syncRoot = SoapServices._soapActions.SyncRoot; string result; lock (syncRoot) { string text = (string)SoapServices._soapActions[mb]; if (text == null) { SoapMethodAttribute soapMethodAttribute = (SoapMethodAttribute)InternalRemotingServices.GetCachedSoapAttribute(mb); text = soapMethodAttribute.SoapAction; SoapServices._soapActions[mb] = text; SoapServices._soapActionsMethods[text] = mb; } result = text; } return(result); }
// Get the SOAP action associated with a method. public static String GetSoapActionFromMethodBase(MethodBase mb) { // See if we have a registered action first. lock (typeof(SoapServices)) { if (methodToAction != null) { String temp = (String)(methodToAction[mb]); if (temp != null) { return(temp); } } } // Get the action from the method itself. return(((SoapMethodAttribute) InternalRemotingServices.GetCachedSoapAttribute(mb)) .SoapAction); }
public static bool GetXmlTypeForInteropType(Type type, out string xmlType, out string xmlTypeNamespace) { SoapServices.XmlEntry xmlEntry = (SoapServices.XmlEntry)SoapServices._interopTypeToXmlType[type]; if (xmlEntry != null) { xmlType = xmlEntry.Name; xmlTypeNamespace = xmlEntry.Namespace; return(true); } SoapTypeAttribute soapTypeAttribute = (SoapTypeAttribute)InternalRemotingServices.GetCachedSoapAttribute(type); if (soapTypeAttribute.IsInteropXmlType()) { xmlType = soapTypeAttribute.XmlTypeName; xmlTypeNamespace = soapTypeAttribute.XmlTypeNamespace; return(true); } xmlType = null; xmlTypeNamespace = null; return(false); }
public static bool GetXmlElementForInteropType(Type type, out string xmlElement, out string xmlNamespace) { XmlEntry entry = (XmlEntry)_interopTypeToXmlElement[type]; if (entry != null) { xmlElement = entry.Name; xmlNamespace = entry.Namespace; return(true); } SoapTypeAttribute cachedSoapAttribute = (SoapTypeAttribute)InternalRemotingServices.GetCachedSoapAttribute(type); if (cachedSoapAttribute.IsInteropXmlElement()) { xmlElement = cachedSoapAttribute.XmlElementName; xmlNamespace = cachedSoapAttribute.XmlNamespace; return(true); } xmlElement = null; xmlNamespace = null; return(false); }
public static string GetSoapActionFromMethodBase(MethodBase mb) { return((string)SoapServices._methodBaseToSoapAction[(object)mb] ?? ((SoapMethodAttribute)InternalRemotingServices.GetCachedSoapAttribute((object)mb)).SoapAction); }
public static string GetXmlNamespaceForMethodCall(MethodBase mb) { return(InternalRemotingServices.GetCachedSoapAttribute((object)mb).XmlNamespace); }
public static bool IsSoapActionValidForMethodBase(string soapAction, MethodBase mb) { if (mb == (MethodBase)null) { throw new ArgumentNullException("mb"); } if ((int)soapAction[0] == 34) { string str = soapAction; int index = str.Length - 1; if ((int)str[index] == 34) { soapAction = soapAction.Substring(1, soapAction.Length - 2); } } if (string.CompareOrdinal(((SoapMethodAttribute)InternalRemotingServices.GetCachedSoapAttribute((object)mb)).SoapAction, soapAction) == 0) { return(true); } string strA = (string)SoapServices._methodBaseToSoapAction[(object)mb]; if (strA != null && string.CompareOrdinal(strA, soapAction) == 0) { return(true); } string[] strArray = soapAction.Split('#'); if (strArray.Length != 2) { return(false); } bool assemblyIncluded; string soapActionNamespace = XmlNamespaceEncoder.GetTypeNameForSoapActionNamespace(strArray[0], out assemblyIncluded); if (soapActionNamespace == null) { return(false); } string str1 = strArray[1]; RuntimeMethodInfo runtimeMethodInfo = mb as RuntimeMethodInfo; RuntimeConstructorInfo runtimeConstructorInfo = mb as RuntimeConstructorInfo; RuntimeModule runtimeModule; if ((MethodInfo)runtimeMethodInfo != (MethodInfo)null) { runtimeModule = runtimeMethodInfo.GetRuntimeModule(); } else { if (!((ConstructorInfo)runtimeConstructorInfo != (ConstructorInfo)null)) { throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeReflectionObject")); } runtimeModule = runtimeConstructorInfo.GetRuntimeModule(); } string str2 = mb.DeclaringType.FullName; if (assemblyIncluded) { str2 = str2 + ", " + runtimeModule.GetRuntimeAssembly().GetSimpleName(); } if (str2.Equals(soapActionNamespace)) { return(mb.Name.Equals(str1)); } return(false); }
// Determine if a SOAP action is valid for a method. public static bool IsSoapActionValidForMethodBase (String soapAction, MethodBase mb) { SoapMethodAttribute mattr; int index, index2; String typeName; String mbTypeName; String assembly; bool hasAssembly; // Remove quotes from the action name. if (soapAction[0] == '"' && soapAction.EndsWith("\"")) { soapAction = soapAction.Substring (1, soapAction.Length - 2); } // If the action matches the attribute, then return true. mattr = (SoapMethodAttribute) InternalRemotingServices.GetCachedSoapAttribute(mb); if (mattr.SoapAction == soapAction) { return(true); } // Determine if the action matches the one registered // with the method. lock (typeof(SoapServices)) { if (methodToAction != null) { String temp = (String)(methodToAction[mb]); if (temp != null && temp == soapAction) { return(true); } } } // Pull apart the action and check its components. index = soapAction.IndexOf('#'); if (index != -1) { typeName = ExtractTypeName (soapAction.Substring(0, index), out hasAssembly); if (typeName != null) { if (hasAssembly) { assembly = mb.DeclaringType.Module .Assembly.FullName; index2 = assembly.IndexOf(','); if (index2 != -1) { assembly = assembly.Substring(0, index2); } mbTypeName = mb.DeclaringType.FullName + ", " + assembly; } else { mbTypeName = mb.DeclaringType.FullName; } if (typeName == mbTypeName) { return(mb.Name == soapAction.Substring(index + 1)); } } } // The action string is not valid. return(false); }
// Get the namespace to use for a method call. public static String GetXmlNamespaceForMethodCall(MethodBase mb) { return(((SoapMethodAttribute) InternalRemotingServices.GetCachedSoapAttribute(mb)) .XmlNamespace); }
public static string GetXmlNamespaceForMethodResponse(MethodBase mb) { return(((SoapMethodAttribute)InternalRemotingServices.GetCachedSoapAttribute((object)mb)).ResponseXmlNamespace); }
} // GetSoapActionFromMethodBase /// <include file='doc\Soap.uex' path='docs/doc[@for="SoapServices.IsSoapActionValidForMethodBase"]/*' /> public static bool IsSoapActionValidForMethodBase(String soapAction, MethodBase mb) { // remove quotation marks if present if ((soapAction[0] == '"') && (soapAction[soapAction.Length - 1] == '"')) { soapAction = soapAction.Substring(1, soapAction.Length - 2); } // compare this to the soapAction on the method base SoapMethodAttribute attr = (SoapMethodAttribute) InternalRemotingServices.GetCachedSoapAttribute(mb); if (String.CompareOrdinal(attr.SoapAction, soapAction) == 0) { return(true); } // check to see if a soap action value is registered for this String registeredSoapAction = (String)_methodBaseToSoapAction[mb]; if (registeredSoapAction != null) { if (String.CompareOrdinal(registeredSoapAction, soapAction) == 0) { return(true); } } // otherwise, parse SOAPAction and verify String typeName, methodName; String[] parts = soapAction.Split(new char[1] { '#' }); if (parts.Length == 2) { bool assemblyIncluded; typeName = XmlNamespaceEncoder.GetTypeNameForSoapActionNamespace( parts[0], out assemblyIncluded); if (typeName == null) { return(false); } methodName = parts[1]; // compare to values of method base (FUTURE: Use more direct method for this) Type type = mb.DeclaringType; String actualTypeName = type.FullName; if (assemblyIncluded) { actualTypeName += ", " + type.Module.Assembly.nGetSimpleName(); } // return true if type and method name are the same return(actualTypeName.Equals(typeName) && mb.Name.Equals(methodName)); } else { return(false); } } // IsSoapActionValidForMethodBase
[System.Security.SecurityCritical] // auto-generated public static void PreLoad(Type type) { if (type == null) { throw new ArgumentNullException("type"); } Contract.EndContractBlock(); if (!(type is RuntimeType)) { throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType")); } // register soap action values MethodInfo[] methods = type.GetMethods(); foreach (MethodInfo mi in methods) { // This will only add an entry to the table if SoapAction was explicitly set // on the SoapMethodAttribute. RegisterSoapActionForMethodBase(mi); } // register interop xml elements and types if specified SoapTypeAttribute attr = (SoapTypeAttribute) InternalRemotingServices.GetCachedSoapAttribute(type); if (attr.IsInteropXmlElement()) { RegisterInteropXmlElement(attr.XmlElementName, attr.XmlNamespace, type); } if (attr.IsInteropXmlType()) { RegisterInteropXmlType(attr.XmlTypeName, attr.XmlTypeNamespace, type); } // construct field maps for mapping xml elements and attributes back to // the correct type int mapCount = 0; XmlToFieldTypeMap map = new XmlToFieldTypeMap(); foreach (FieldInfo field in type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly)) { SoapFieldAttribute fieldAttr = (SoapFieldAttribute) InternalRemotingServices.GetCachedSoapAttribute(field); if (fieldAttr.IsInteropXmlElement()) { String xmlName = fieldAttr.XmlElementName; String xmlNamespace = fieldAttr.XmlNamespace; if (fieldAttr.UseAttribute) { map.AddXmlAttribute(field.FieldType, field.Name, xmlName, xmlNamespace); } else { map.AddXmlElement(field.FieldType, field.Name, xmlName, xmlNamespace); } mapCount++; } } // foreach field // add field map if there is more than one entry if (mapCount > 0) { _xmlToFieldTypeMap[type] = map; } } // PreLoad
[System.Security.SecurityCritical] // auto-generated public static bool IsSoapActionValidForMethodBase(String soapAction, MethodBase mb) { if (mb == null) { throw new ArgumentNullException("mb"); } // remove quotation marks if present if ((soapAction[0] == '"') && (soapAction[soapAction.Length - 1] == '"')) { soapAction = soapAction.Substring(1, soapAction.Length - 2); } // compare this to the soapAction on the method base SoapMethodAttribute attr = (SoapMethodAttribute) InternalRemotingServices.GetCachedSoapAttribute(mb); if (String.CompareOrdinal(attr.SoapAction, soapAction) == 0) { return(true); } // check to see if a soap action value is registered for this String registeredSoapAction = (String)_methodBaseToSoapAction[mb]; if (registeredSoapAction != null) { if (String.CompareOrdinal(registeredSoapAction, soapAction) == 0) { return(true); } } // otherwise, parse SOAPAction and verify String typeName, methodName; String[] parts = soapAction.Split(new char[1] { '#' }); if (parts.Length == 2) { bool assemblyIncluded; typeName = XmlNamespaceEncoder.GetTypeNameForSoapActionNamespace( parts[0], out assemblyIncluded); if (typeName == null) { return(false); } methodName = parts[1]; // compare to values of method base ( RuntimeMethodInfo rmi = mb as RuntimeMethodInfo; RuntimeConstructorInfo rci = mb as RuntimeConstructorInfo; RuntimeModule rtModule; if (rmi != null) { rtModule = rmi.GetRuntimeModule(); } else if (rci != null) { rtModule = rci.GetRuntimeModule(); } else { throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeReflectionObject")); } String actualTypeName = mb.DeclaringType.FullName; if (assemblyIncluded) { actualTypeName += ", " + rtModule.GetRuntimeAssembly().GetSimpleName(); } // return true if type and method name are the same return(actualTypeName.Equals(typeName) && mb.Name.Equals(methodName)); } else { return(false); } } // IsSoapActionValidForMethodBase