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));
        }
예제 #2
0
        /// <summary>Determines the type and method name of the method associated with the specified SOAPAction value.</summary>
        /// <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>
        /// <returns>
        ///     <see langword="true" /> if the type and method name were successfully recovered; otherwise, <see langword="false" />.</returns>
        /// <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>
        // Token: 0x06005598 RID: 21912 RVA: 0x0012F168 File Offset: 0x0012D368
        public static bool GetTypeAndMethodNameFromSoapAction(string soapAction, out string typeName, out string methodName)
        {
            if (soapAction[0] == '"' && soapAction[soapAction.Length - 1] == '"')
            {
                soapAction = soapAction.Substring(1, soapAction.Length - 2);
            }
            ArrayList arrayList = (ArrayList)SoapServices._soapActionToMethodBase[soapAction];

            if (arrayList != null)
            {
                if (arrayList.Count > 1)
                {
                    typeName   = null;
                    methodName = null;
                    return(false);
                }
                MethodBase methodBase = (MethodBase)arrayList[0];
                if (methodBase != null)
                {
                    RuntimeMethodInfo      runtimeMethodInfo      = methodBase as RuntimeMethodInfo;
                    RuntimeConstructorInfo runtimeConstructorInfo = methodBase as RuntimeConstructorInfo;
                    RuntimeModule          runtimeModule;
                    if (runtimeMethodInfo != null)
                    {
                        runtimeModule = runtimeMethodInfo.GetRuntimeModule();
                    }
                    else
                    {
                        if (!(runtimeConstructorInfo != null))
                        {
                            throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeReflectionObject"));
                        }
                        runtimeModule = runtimeConstructorInfo.GetRuntimeModule();
                    }
                    typeName   = methodBase.DeclaringType.FullName + ", " + runtimeModule.GetRuntimeAssembly().GetSimpleName();
                    methodName = methodBase.Name;
                    return(true);
                }
            }
            string[] array = soapAction.Split(new char[]
            {
                '#'
            });
            if (array.Length != 2)
            {
                typeName   = null;
                methodName = null;
                return(false);
            }
            bool flag;

            typeName = XmlNamespaceEncoder.GetTypeNameForSoapActionNamespace(array[0], out flag);
            if (typeName == null)
            {
                methodName = null;
                return(false);
            }
            methodName = array[1];
            return(true);
        }
        public static bool GetTypeAndMethodNameFromSoapAction(string soapAction, out string typeName, out string methodName)
        {
            if ((soapAction[0] == '"') && (soapAction[soapAction.Length - 1] == '"'))
            {
                soapAction = soapAction.Substring(1, soapAction.Length - 2);
            }
            ArrayList list = (ArrayList)_soapActionToMethodBase[soapAction];

            if (list != null)
            {
                if (list.Count > 1)
                {
                    typeName   = null;
                    methodName = null;
                    return(false);
                }
                MethodBase base2 = (MethodBase)list[0];
                if (base2 != null)
                {
                    RuntimeModule          runtimeModule;
                    RuntimeMethodInfo      info  = base2 as RuntimeMethodInfo;
                    RuntimeConstructorInfo info2 = base2 as RuntimeConstructorInfo;
                    if (info != null)
                    {
                        runtimeModule = info.GetRuntimeModule();
                    }
                    else
                    {
                        if (info2 == null)
                        {
                            throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeReflectionObject"));
                        }
                        runtimeModule = info2.GetRuntimeModule();
                    }
                    typeName   = base2.DeclaringType.FullName + ", " + runtimeModule.GetRuntimeAssembly().GetSimpleName();
                    methodName = base2.Name;
                    return(true);
                }
            }
            string[] strArray = soapAction.Split(new char[] { '#' });
            if (strArray.Length == 2)
            {
                bool flag;
                typeName = XmlNamespaceEncoder.GetTypeNameForSoapActionNamespace(strArray[0], out flag);
                if (typeName == null)
                {
                    methodName = null;
                    return(false);
                }
                methodName = strArray[1];
                return(true);
            }
            typeName   = null;
            methodName = null;
            return(false);
        }
예제 #4
0
파일: soap.cs 프로젝트: dox0/DotNet471RS3
        } // IsSoapActionValidForMethodBase

        public static bool GetTypeAndMethodNameFromSoapAction(String soapAction,
                                                              out String typeName,
                                                              out String methodName)
        {
            // remove quotation marks if present
            if ((soapAction[0] == '"') && (soapAction[soapAction.Length - 1] == '"'))
            {
                soapAction = soapAction.Substring(1, soapAction.Length - 2);
            }

            ArrayList mbTable = (ArrayList)_soapActionToMethodBase[soapAction];

            if (mbTable != null)
            {
                // indicate that we can't resolve soap action to type and method name
                if (mbTable.Count > 1)
                {
                    typeName   = null;
                    methodName = null;
                    return(false);
                }

                MethodBase mb = (MethodBase)mbTable[0];
                if (mb != null)
                {
                    // 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"));
                    }

                    typeName   = mb.DeclaringType.FullName + ", " + rtModule.GetRuntimeAssembly().GetSimpleName();
                    methodName = mb.Name;
                    return(true);
                }
            }


            String[] parts = soapAction.Split(new char[1] {
                '#'
            });
            if (parts.Length == 2)
            {
                bool assemblyIncluded;
                typeName = XmlNamespaceEncoder.GetTypeNameForSoapActionNamespace(
                    parts[0], out assemblyIncluded);
                if (typeName == null)
                {
                    methodName = null;
                    return(false);
                }

                methodName = parts[1];
                return(true);
            }
            else
            {
                typeName   = null;
                methodName = null;
                return(false);
            }
        } // GetTypeAndMethodNameFromSoapAction
예제 #5
0
파일: soap.cs 프로젝트: dox0/DotNet471RS3
        [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
예제 #6
0
        /// <summary>确定与指定的 SOAPAction 值关联的方法的类型和方法名。</summary>
        /// <returns>如果类型和方法名成功恢复,则为 true;否则为 false。</returns>
        /// <param name="soapAction">为其请求类型和方法名的方法的 SOAPAction。</param>
        /// <param name="typeName">当此方法返回时,该参数包含保存了相关方法的类型名称的 <see cref="T:System.String" />。该参数未经初始化即被传递。</param>
        /// <param name="methodName">当此方法返回时,该参数包含保存了相关方法的方法名的 <see cref="T:System.String" />。该参数未经初始化即被传递。</param>
        /// <exception cref="T:System.Runtime.Remoting.RemotingException">SOAPAction 值不以引号开头和结尾。</exception>
        /// <exception cref="T:System.Security.SecurityException">直接调用方没有基础结构权限。</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)
        {
            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);
                }
            }
            ArrayList arrayList = (ArrayList)SoapServices._soapActionToMethodBase[(object)soapAction];

            if (arrayList != null)
            {
                if (arrayList.Count > 1)
                {
                    typeName   = (string)null;
                    methodName = (string)null;
                    return(false);
                }
                MethodBase methodBase = (MethodBase)arrayList[0];
                if (methodBase != (MethodBase)null)
                {
                    RuntimeMethodInfo      runtimeMethodInfo      = methodBase as RuntimeMethodInfo;
                    RuntimeConstructorInfo runtimeConstructorInfo = methodBase 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();
                    }
                    typeName   = methodBase.DeclaringType.FullName + ", " + runtimeModule.GetRuntimeAssembly().GetSimpleName();
                    methodName = methodBase.Name;
                    return(true);
                }
            }
            string[] strArray = soapAction.Split('#');
            if (strArray.Length == 2)
            {
                bool assemblyIncluded;
                typeName = XmlNamespaceEncoder.GetTypeNameForSoapActionNamespace(strArray[0], out assemblyIncluded);
                if (typeName == null)
                {
                    methodName = (string)null;
                    return(false);
                }
                methodName = strArray[1];
                return(true);
            }
            typeName   = (string)null;
            methodName = (string)null;
            return(false);
        }
예제 #7
0
        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);
        }