using System; using System.Collections; using System.Reflection; using System.Runtime.InteropServices; using System.Runtime.Remoting.Metadata; namespace System.Runtime.Remoting { /// Provides several methods for using and publishing remoted objects in SOAP format. // Token: 0x02000454 RID: 1108 [ComVisible(true)] public class SoapServices { // Token: 0x06002AAE RID: 10926 RVA: 0x0008A4F0 File Offset: 0x000886F0 private SoapServices() { } /// Gets the XML namespace prefix for common language runtime types. /// The XML namespace prefix for common language runtime types. /// The immediate caller does not have infrastructure permission. /// /// /// // Token: 0x17000866 RID: 2150 // (get) Token: 0x06002AB0 RID: 10928 RVA: 0x0008A538 File Offset: 0x00088738 public static string XmlNsForClrType { get { return "http://schemas.microsoft.com/clr/"; } } /// Gets the default XML namespace prefix that should be used for XML encoding of a common language runtime class that has an assembly, but no native namespace. /// The default XML namespace prefix that should be used for XML encoding of a common language runtime class that has an assembly, but no native namespace. /// The immediate caller does not have infrastructure permission. /// /// /// // Token: 0x17000867 RID: 2151 // (get) Token: 0x06002AB1 RID: 10929 RVA: 0x0008A540 File Offset: 0x00088740 public static string XmlNsForClrTypeWithAssembly { get { return "http://schemas.microsoft.com/clr/assem/"; } } /// Gets the XML namespace prefix that should be used for XML encoding of a common language runtime class that is part of the mscorlib.dll file. /// The XML namespace prefix that should be used for XML encoding of a common language runtime class that is part of the mscorlib.dll file. /// The immediate caller does not have infrastructure permission. /// /// /// // Token: 0x17000868 RID: 2152 // (get) Token: 0x06002AB2 RID: 10930 RVA: 0x0008A548 File Offset: 0x00088748 public static string XmlNsForClrTypeWithNs { get { return "http://schemas.microsoft.com/clr/ns/"; } } /// Gets the default XML namespace prefix that should be used for XML encoding of a common language runtime class that has both a common language runtime namespace and an assembly. /// The default XML namespace prefix that should be used for XML encoding of a common language runtime class that has both a common language runtime namespace and an assembly. /// The immediate caller does not have infrastructure permission. /// /// /// // Token: 0x17000869 RID: 2153 // (get) Token: 0x06002AB3 RID: 10931 RVA: 0x0008A550 File Offset: 0x00088750 public static string XmlNsForClrTypeWithNsAndAssembly { get { return "http://schemas.microsoft.com/clr/nsassem/"; } } /// Returns the common language runtime type namespace name from the provided namespace and assembly names. /// The common language runtime type namespace name from the provided namespace and assembly names. /// The namespace that is to be coded. /// The name of the assembly that is to be coded. /// The and parameters are both either null or empty. /// The immediate caller does not have infrastructure permission. /// /// /// // Token: 0x06002AB4 RID: 10932 RVA: 0x0008A558 File Offset: 0x00088758 public static string CodeXmlNamespaceForClrTypeNamespace(string typeNamespace, string assemblyName) { if (assemblyName == string.Empty) { return SoapServices.XmlNsForClrTypeWithNs + typeNamespace; } if (typeNamespace == string.Empty) { return SoapServices.EncodeNs(SoapServices.XmlNsForClrTypeWithAssembly + assemblyName); } return SoapServices.EncodeNs(SoapServices.XmlNsForClrTypeWithNsAndAssembly + typeNamespace + "/" + assemblyName); } /// Decodes the XML namespace and assembly names from the provided common language runtime namespace. /// true if the namespace and assembly names were successfully decoded; otherwise, false. /// The common language runtime namespace. /// When this method returns, contains a that holds the decoded namespace name. This parameter is passed uninitialized. /// When this method returns, contains a that holds the decoded assembly name. This parameter is passed uninitialized. /// The parameter is null or empty. /// The immediate caller does not have infrastructure permission. /// /// /// // Token: 0x06002AB5 RID: 10933 RVA: 0x0008A5B8 File Offset: 0x000887B8 public static bool DecodeXmlNamespaceForClrTypeNamespace(string inNamespace, out string typeNamespace, out string assemblyName) { if (inNamespace == null) { throw new ArgumentNullException("inNamespace"); } inNamespace = SoapServices.DecodeNs(inNamespace); typeNamespace = null; assemblyName = null; if (inNamespace.StartsWith(SoapServices.XmlNsForClrTypeWithNsAndAssembly)) { int length = SoapServices.XmlNsForClrTypeWithNsAndAssembly.Length; if (length >= inNamespace.Length) { return false; } int num = inNamespace.IndexOf('/', length + 1); if (num == -1) { return false; } typeNamespace = inNamespace.Substring(length, num - length); assemblyName = inNamespace.Substring(num + 1); return true; } else { if (inNamespace.StartsWith(SoapServices.XmlNsForClrTypeWithNs)) { int length2 = SoapServices.XmlNsForClrTypeWithNs.Length; typeNamespace = inNamespace.Substring(length2); return true; } if (inNamespace.StartsWith(SoapServices.XmlNsForClrTypeWithAssembly)) { int length3 = SoapServices.XmlNsForClrTypeWithAssembly.Length; assemblyName = inNamespace.Substring(length3); return true; } return false; } } /// Retrieves field type from XML attribute name, namespace, and the of the containing object. /// The of the object that contains the field. /// The XML attribute name of the field type. /// The XML namespace of the field type. /// When this method returns, contains a of the field. This parameter is passed uninitialized. /// When this method returns, contains a that holds the name of the field. This parameter is passed uninitialized. /// The immediate caller does not have infrastructure permission. /// /// /// // Token: 0x06002AB6 RID: 10934 RVA: 0x0008A688 File Offset: 0x00088888 public static void GetInteropFieldTypeAndNameFromXmlAttribute(Type containingType, string xmlAttribute, string xmlNamespace, out Type type, out string name) { SoapServices.TypeInfo typeInfo = (SoapServices.TypeInfo)SoapServices._typeInfos[containingType]; Hashtable hashtable = ((typeInfo == null) ? null : typeInfo.Attributes); SoapServices.GetInteropFieldInfo(hashtable, xmlAttribute, xmlNamespace, out type, out name); } /// Retrieves the and name of a field from the provided XML element name, namespace, and the containing type. /// The of the object that contains the field. /// The XML element name of field. /// The XML namespace of the field type. /// When this method returns, contains a of the field. This parameter is passed uninitialized. /// When this method returns, contains a that holds the name of the field. This parameter is passed uninitialized. /// The immediate caller does not have infrastructure permission. /// /// /// // Token: 0x06002AB7 RID: 10935 RVA: 0x0008A6C4 File Offset: 0x000888C4 public static void GetInteropFieldTypeAndNameFromXmlElement(Type containingType, string xmlElement, string xmlNamespace, out Type type, out string name) { SoapServices.TypeInfo typeInfo = (SoapServices.TypeInfo)SoapServices._typeInfos[containingType]; Hashtable hashtable = ((typeInfo == null) ? null : typeInfo.Elements); SoapServices.GetInteropFieldInfo(hashtable, xmlElement, xmlNamespace, out type, out name); } // Token: 0x06002AB8 RID: 10936 RVA: 0x0008A700 File Offset: 0x00088900 private static void GetInteropFieldInfo(Hashtable fields, string xmlName, string xmlNamespace, out Type type, out string name) { if (fields != null) { FieldInfo fieldInfo = (FieldInfo)fields[SoapServices.GetNameKey(xmlName, xmlNamespace)]; if (fieldInfo != null) { type = fieldInfo.FieldType; name = fieldInfo.Name; return; } } type = null; name = null; } // Token: 0x06002AB9 RID: 10937 RVA: 0x0008A748 File Offset: 0x00088948 private static string GetNameKey(string name, string namspace) { if (namspace == null) { return name; } return name + " " + namspace; } /// Retrieves the that should be used during deserialization of an unrecognized object type with the given XML element name and namespace. /// The of object associated with the specified XML element name and namespace. /// The XML element name of the unknown object type. /// The XML namespace of the unknown object type. /// The immediate caller does not have infrastructure permission. /// /// /// // Token: 0x06002ABA RID: 10938 RVA: 0x0008A760 File Offset: 0x00088960 public static Type GetInteropTypeFromXmlElement(string xmlElement, string xmlNamespace) { object syncRoot = SoapServices._xmlElements.SyncRoot; Type type; lock (syncRoot) { type = (Type)SoapServices._xmlElements[xmlElement + " " + xmlNamespace]; } return type; } /// Retrieves the object that should be used during deserialization of an unrecognized object type with the given XML type name and namespace. /// The of object associated with the specified XML type name and namespace. /// The XML type of the unknown object type. /// The XML type namespace of the unknown object type. /// The immediate caller does not have infrastructure permission. /// /// /// // Token: 0x06002ABB RID: 10939 RVA: 0x0008A7C8 File Offset: 0x000889C8 public static Type GetInteropTypeFromXmlType(string xmlType, string xmlTypeNamespace) { object syncRoot = SoapServices._xmlTypes.SyncRoot; Type type; lock (syncRoot) { type = (Type)SoapServices._xmlTypes[xmlType + " " + xmlTypeNamespace]; } return type; } // Token: 0x06002ABC RID: 10940 RVA: 0x0008A830 File Offset: 0x00088A30 private static string GetAssemblyName(MethodBase mb) { if (mb.DeclaringType.Assembly == typeof(object).Assembly) { return string.Empty; } return mb.DeclaringType.Assembly.GetName().Name; } /// Returns the SOAPAction value associated with the method specified in the given . /// The SOAPAction value associated with the method specified in the given . /// The that contains the method for which a SOAPAction is requested. /// The immediate caller does not have infrastructure permission. /// /// /// // Token: 0x06002ABD RID: 10941 RVA: 0x0008A878 File Offset: 0x00088A78 public static string GetSoapActionFromMethodBase(MethodBase mb) { return SoapServices.InternalGetSoapAction(mb); } /// Determines the type and method name of the method associated with the specified SOAPAction value. /// true if the type and method name were successfully recovered; otherwise, false. /// The SOAPAction of the method for which the type and method names were requested. /// When this method returns, contains a that holds the type name of the method in question. This parameter is passed uninitialized. /// When this method returns, contains a that holds the method name of the method in question. This parameter is passed uninitialized. /// The SOAPAction value does not start and end with quotes. /// The immediate caller does not have infrastructure permission. /// /// /// // Token: 0x06002ABE RID: 10942 RVA: 0x0008A880 File Offset: 0x00088A80 public static bool GetTypeAndMethodNameFromSoapAction(string soapAction, out string typeName, out string methodName) { object syncRoot = SoapServices._soapActions.SyncRoot; lock (syncRoot) { MethodBase methodBase = (MethodBase)SoapServices._soapActionsMethods[soapAction]; if (methodBase != null) { typeName = methodBase.DeclaringType.AssemblyQualifiedName; methodName = methodBase.Name; return true; } } typeName = null; methodName = null; int num = soapAction.LastIndexOf('#'); if (num == -1) { return false; } methodName = soapAction.Substring(num + 1); string text; string text2; if (!SoapServices.DecodeXmlNamespaceForClrTypeNamespace(soapAction.Substring(0, num), out text, out text2)) { return false; } if (text2 == null) { typeName = text + ", " + typeof(object).Assembly.GetName().Name; } else { typeName = text + ", " + text2; } return true; } /// Returns XML element information that should be used when serializing the given type. /// true if the requested values have been set flagged with ; otherwise, false. /// The object for which the XML element and namespace names were requested. /// When this method returns, contains a that holds the XML element name of the specified object type. This parameter is passed uninitialized. /// When this method returns, contains a that holds the XML namespace name of the specified object type. This parameter is passed uninitialized. /// The immediate caller does not have infrastructure permission. /// /// /// // Token: 0x06002ABF RID: 10943 RVA: 0x0008A97C File Offset: 0x00088B7C public static bool GetXmlElementForInteropType(Type type, out string xmlElement, out string xmlNamespace) { SoapTypeAttribute soapTypeAttribute = (SoapTypeAttribute)InternalRemotingServices.GetCachedSoapAttribute(type); if (!soapTypeAttribute.IsInteropXmlElement) { xmlElement = null; xmlNamespace = null; return false; } xmlElement = soapTypeAttribute.XmlElementName; xmlNamespace = soapTypeAttribute.XmlNamespace; return true; } /// Retrieves the XML namespace used during remote calls of the method specified in the given . /// The XML namespace used during remote calls of the specified method. /// The of the method for which the XML namespace was requested. /// The immediate caller does not have infrastructure permission. /// /// /// // Token: 0x06002AC0 RID: 10944 RVA: 0x0008A9BC File Offset: 0x00088BBC public static string GetXmlNamespaceForMethodCall(MethodBase mb) { return SoapServices.CodeXmlNamespaceForClrTypeNamespace(mb.DeclaringType.FullName, SoapServices.GetAssemblyName(mb)); } /// Retrieves the XML namespace used during the generation of responses to the remote call to the method specified in the given . /// The XML namespace used during the generation of responses to a remote method call. /// The of the method for which the XML namespace was requested. /// The immediate caller does not have infrastructure permission. /// /// /// // Token: 0x06002AC1 RID: 10945 RVA: 0x0008A9D4 File Offset: 0x00088BD4 public static string GetXmlNamespaceForMethodResponse(MethodBase mb) { return SoapServices.CodeXmlNamespaceForClrTypeNamespace(mb.DeclaringType.FullName, SoapServices.GetAssemblyName(mb)); } /// Returns XML type information that should be used when serializing the given . /// true if the requested values have been set flagged with ; otherwise, false. /// The object for which the XML element and namespace names were requested. /// The XML type of the specified object . /// The XML type namespace of the specified object . /// The immediate caller does not have infrastructure permission. /// /// /// // Token: 0x06002AC2 RID: 10946 RVA: 0x0008A9EC File Offset: 0x00088BEC 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; } /// Returns a Boolean value that indicates whether the specified namespace is native to the common language runtime. /// true if the given namespace is native to the common language runtime; otherwise, false. /// The namespace to check in the common language runtime. /// The immediate caller does not have infrastructure permission. /// /// /// // Token: 0x06002AC3 RID: 10947 RVA: 0x0008AA2C File Offset: 0x00088C2C public static bool IsClrTypeNamespace(string namespaceString) { return namespaceString.StartsWith(SoapServices.XmlNsForClrType); } /// Determines if the specified SOAPAction is acceptable for a given . /// true if the specified SOAPAction is acceptable for a given ; otherwise, false. /// The SOAPAction to check against the given . /// The the specified SOAPAction is checked against. /// The immediate caller does not have infrastructure permission. /// /// /// // Token: 0x06002AC4 RID: 10948 RVA: 0x0008AA3C File Offset: 0x00088C3C public static bool IsSoapActionValidForMethodBase(string soapAction, MethodBase mb) { string text; string text2; SoapServices.GetTypeAndMethodNameFromSoapAction(soapAction, out text, out text2); if (text2 != mb.Name) { return false; } string assemblyQualifiedName = mb.DeclaringType.AssemblyQualifiedName; return text == assemblyQualifiedName; } /// Preloads every found in the specified from the information found in the associated with each type. /// The for each type of which to call . /// The immediate caller does not have infrastructure permission. /// /// /// // Token: 0x06002AC5 RID: 10949 RVA: 0x0008AA7C File Offset: 0x00088C7C public static void PreLoad(Assembly assembly) { foreach (Type type in assembly.GetTypes()) { SoapServices.PreLoad(type); } } /// Preloads the given based on values set in a on the type. /// The to preload. /// The immediate caller does not have infrastructure permission. /// /// /// // Token: 0x06002AC6 RID: 10950 RVA: 0x0008AAB0 File Offset: 0x00088CB0 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; } } /// Associates the given XML element name and namespace with a run-time type that should be used for deserialization. /// The XML element name to use in deserialization. /// The XML namespace to use in deserialization. /// The run-time to use in deserialization. /// The immediate caller does not have infrastructure permission. /// /// /// // Token: 0x06002AC7 RID: 10951 RVA: 0x0008AC0C File Offset: 0x00088E0C public static void RegisterInteropXmlElement(string xmlElement, string xmlNamespace, Type type) { object syncRoot = SoapServices._xmlElements.SyncRoot; lock (syncRoot) { SoapServices._xmlElements[xmlElement + " " + xmlNamespace] = type; } } /// Associates the given XML type name and namespace with the run-time type that should be used for deserialization. /// The XML type to use in deserialization. /// The XML namespace to use in deserialization. /// The run-time to use in deserialization. /// The immediate caller does not have infrastructure permission. /// /// /// // Token: 0x06002AC8 RID: 10952 RVA: 0x0008AC6C File Offset: 0x00088E6C public static void RegisterInteropXmlType(string xmlType, string xmlTypeNamespace, Type type) { object syncRoot = SoapServices._xmlTypes.SyncRoot; lock (syncRoot) { SoapServices._xmlTypes[xmlType + " " + xmlTypeNamespace] = type; } } /// Associates the specified with the SOAPAction cached with it. /// The of the method to associate with the SOAPAction cached with it. /// The immediate caller does not have infrastructure permission. /// /// /// // Token: 0x06002AC9 RID: 10953 RVA: 0x0008ACCC File Offset: 0x00088ECC public static void RegisterSoapActionForMethodBase(MethodBase mb) { SoapServices.InternalGetSoapAction(mb); } // Token: 0x06002ACA RID: 10954 RVA: 0x0008ACD8 File Offset: 0x00088ED8 private static string InternalGetSoapAction(MethodBase mb) { object syncRoot = SoapServices._soapActions.SyncRoot; string text2; 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; } text2 = text; } return text2; } /// Associates the provided SOAPAction value with the given for use in channel sinks. /// The to associate with the provided SOAPAction. /// The SOAPAction value to associate with the given . /// The immediate caller does not have infrastructure permission. /// /// /// // Token: 0x06002ACB RID: 10955 RVA: 0x0008AD68 File Offset: 0x00088F68 public static void RegisterSoapActionForMethodBase(MethodBase mb, string soapAction) { object syncRoot = SoapServices._soapActions.SyncRoot; lock (syncRoot) { SoapServices._soapActions[mb] = soapAction; SoapServices._soapActionsMethods[soapAction] = mb; } } // Token: 0x06002ACC RID: 10956 RVA: 0x0008ADC8 File Offset: 0x00088FC8 private static string EncodeNs(string ns) { ns = ns.Replace(",", "%2C"); ns = ns.Replace(" ", "%20"); return ns.Replace("=", "%3D"); } // Token: 0x06002ACD RID: 10957 RVA: 0x0008AE0C File Offset: 0x0008900C private static string DecodeNs(string ns) { ns = ns.Replace("%2C", ","); ns = ns.Replace("%20", " "); return ns.Replace("%3D", "="); } // Token: 0x04001053 RID: 4179 private static Hashtable _xmlTypes = new Hashtable(); // Token: 0x04001054 RID: 4180 private static Hashtable _xmlElements = new Hashtable(); // Token: 0x04001055 RID: 4181 private static Hashtable _soapActions = new Hashtable(); // Token: 0x04001056 RID: 4182 private static Hashtable _soapActionsMethods = new Hashtable(); // Token: 0x04001057 RID: 4183 private static Hashtable _typeInfos = new Hashtable(); // Token: 0x02000455 RID: 1109 private class TypeInfo { // Token: 0x04001058 RID: 4184 public Hashtable Attributes; // Token: 0x04001059 RID: 4185 public Hashtable Elements; } } }