System.Runtime.Remoting.SoapServices.DecodeXmlNamespaceForClrTypeNamespace C# (CSharp) Method

DecodeXmlNamespaceForClrTypeNamespace() public static method

public static DecodeXmlNamespaceForClrTypeNamespace ( String inNamespace, String &typeNamespace, String &assemblyName ) : bool
inNamespace String
typeNamespace String
assemblyName String
return bool
        public static bool DecodeXmlNamespaceForClrTypeNamespace(String inNamespace, out String typeNamespace, out String assemblyName)
        {
            if (IsNameNull(inNamespace))
                throw new ArgumentNullException("inNamespace");

            assemblyName = null;
            typeNamespace = "";

            if (inNamespace.StartsWith(assemblyNS, StringComparison.Ordinal))
                assemblyName = UriDecode(inNamespace.Substring(assemblyNS.Length));
            else if (inNamespace.StartsWith(namespaceNS, StringComparison.Ordinal))
                typeNamespace = inNamespace.Substring(namespaceNS.Length);
            else if (inNamespace.StartsWith(fullNS, StringComparison.Ordinal))
            {
                int index = inNamespace.IndexOf("/", fullNS.Length);
                typeNamespace = inNamespace.Substring(fullNS.Length,index-fullNS.Length);
                assemblyName = UriDecode(inNamespace.Substring(index+1));
            }
            else
                return false;

            return true;
        }

Usage Example

示例#1
0
        /// <summary>Determines the type and method name of the method associated with the specified SOAPAction value.</summary>
        /// <returns>true if the type and method name were successfully recovered; otherwise, false.</returns>
        /// <param name="soapAction">The SOAPAction of the method for which the type and method names were requested. </param>
        /// <param name="typeName">When this method returns, contains a <see cref="T:System.String" /> that holds the type name of the method in question. This parameter is passed uninitialized. </param>
        /// <param name="methodName">When this method returns, contains a <see cref="T:System.String" /> that holds the method name of the method in question. This parameter is passed uninitialized. </param>
        /// <exception cref="T:System.Runtime.Remoting.RemotingException">The SOAPAction value does not start and end with quotes. </exception>
        /// <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 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 str;
            string text;

            if (!SoapServices.DecodeXmlNamespaceForClrTypeNamespace(soapAction.Substring(0, num), out str, out text))
            {
                return(false);
            }
            if (text == null)
            {
                typeName = str + ", " + typeof(object).Assembly.GetName().Name;
            }
            else
            {
                typeName = str + ", " + text;
            }
            return(true);
        }