private void ResolveOverloadedMethod(RuntimeType t, string methodName, ArrayList argNames, ArrayList argValues)
        {
            System.Reflection.MethodBase base2;
            MemberInfo[] infoArray = t.GetMember(methodName, MemberTypes.Method, BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance);
            int length = infoArray.Length;
            switch (length)
            {
                case 1:
                    this.MI = infoArray[0] as System.Reflection.MethodBase;
                    return;

                case 0:
                    return;

                default:
                    base2 = null;
                    for (int i = 0; i < length; i++)
                    {
                        System.Reflection.MethodBase base3 = infoArray[i] as System.Reflection.MethodBase;
                        ParameterInfo[] parameters = base3.GetParameters();
                        if (parameters.Length == argValues.Count)
                        {
                            bool flag = true;
                            for (int j = 0; j < parameters.Length; j++)
                            {
                                Type parameterType = parameters[j].ParameterType;
                                if (parameterType.IsByRef)
                                {
                                    parameterType = parameterType.GetElementType();
                                }
                                if (parameterType != argValues[j].GetType())
                                {
                                    flag = false;
                                    break;
                                }
                            }
                            if (flag)
                            {
                                base2 = base3;
                                break;
                            }
                        }
                    }
                    break;
            }
            if (base2 == null)
            {
                throw new RemotingException(Environment.GetResourceString("Remoting_AmbiguousMethod"));
            }
            this.MI = base2;
        }
Ejemplo n.º 2
0
        // This will find the right overloaded method if the argValues from soap have type information,
        // By default parameters will be of type string, this could lead to a wrong choice of methodbase.
        void ResolveOverloadedMethod(RuntimeType t, String methodName, ArrayList argNames, ArrayList argValues)
        {
            MemberInfo[] canidates = t.GetMember(methodName, MemberTypes.Method, MethodCall.LookupPublic);

            int canidatesCount = canidates.Length;

            if (canidatesCount == 1)
            {
                MI = canidates[0] as MethodBase;
                return;
            }
                

            if (canidatesCount == 0)
                return;

            MethodBase match = null;

            for (int i = 0; i < canidatesCount; i++)
            {
                MethodBase canidate = canidates[i] as MethodBase;

                ParameterInfo[] parameters = canidate.GetParameters();

                if (parameters.Length == argValues.Count)
                {
                    bool isMatch = true;
                    for (int j = 0; j < parameters.Length; j++)
                    {
                        Type parameterType = parameters[j].ParameterType;

                        if (parameterType.IsByRef)
                            parameterType = parameterType.GetElementType();

                        if (parameterType != argValues[j].GetType())
                        {
                            isMatch = false;
                            break;
                        }

                    }
                    if (isMatch)
                    {
                        match = canidate;
                        break;
                    }
                }
            }
            if (match == null)
                throw new RemotingException(Environment.GetResourceString("Remoting_AmbiguousMethod"));
            MI = match;
        }
        private void ResolveOverloadedMethod(RuntimeType t)
        {
            if (this.args != null)
            {
                MemberInfo[] infoArray = t.GetMember(this.methodName, MemberTypes.Method, BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance);
                int length = infoArray.Length;
                switch (length)
                {
                    case 1:
                        this.MI = infoArray[0] as System.Reflection.MethodBase;
                        return;

                    case 0:
                        return;
                }
                int num2 = this.args.Length;
                System.Reflection.MethodBase base2 = null;
                for (int i = 0; i < length; i++)
                {
                    System.Reflection.MethodBase base3 = infoArray[i] as System.Reflection.MethodBase;
                    if (base3.GetParameters().Length == num2)
                    {
                        if (base2 != null)
                        {
                            throw new RemotingException(Environment.GetResourceString("Remoting_AmbiguousMethod"));
                        }
                        base2 = base3;
                    }
                }
                if (base2 != null)
                {
                    this.MI = base2;
                }
            }
        }
Ejemplo n.º 4
0
        // Helper that gets called when we attempt to resolve a method
        // without an accompanying methodSignature ... current thinking is
        // that we should make a good faith attempt by matching argument
        // counts

        void ResolveOverloadedMethod(RuntimeType t)
        {
            // args is null the first call from soap because we havem't passed the arguments yet.
            if (args == null) 
                return;

            MemberInfo[] canidates = t.GetMember(methodName, MemberTypes.Method, MethodCall.LookupPublic);

            int canidatesCount = canidates.Length;

            if (canidatesCount == 1)
            {
                MI = canidates[0] as MethodBase;
                return;
            }

            if (canidatesCount == 0)
                return;

            int argCount = args.Length;
            MethodBase match = null;

            // We will let resolve succeed if exactly one of the overloaded methods matches in terms of argCount
            for (int i = 0; i < canidatesCount; i++)
            {
                MethodBase canidate = canidates[i] as MethodBase;
                if (canidate.GetParameters().Length == argCount)
                {
                    if (match != null)
                        throw new RemotingException(Environment.GetResourceString("Remoting_AmbiguousMethod"));

                    match = canidate;
                } 
            }

            if (match != null)
                MI = match;
        }