clojure.lang.Reflector.GetMatchingMethodAux C# (CSharp) Метод

GetMatchingMethodAux() приватный статический Метод

Select matching method from list based on args.
private static GetMatchingMethodAux ( Type targetType, IList args, IList methods, string methodName, bool isStatic ) : MethodBase
targetType System.Type
args IList
methods IList
methodName string
isStatic bool
Результат System.Reflection.MethodBase
        private static MethodBase GetMatchingMethodAux(Type targetType, IList<HostArg> args, IList<MethodBase> methods, string methodName, bool isStatic)
        {
            int argCount = args.Count;

            if (methods.Count == 0)
                return null;

            if (methods.Count == 1)
                return methods[0];

            IList<DynamicMetaObject> argsPlus = new List<DynamicMetaObject>(argCount + (isStatic ? 0 : 1));
            if (!isStatic)
                argsPlus.Add(new DynamicMetaObject(Expression.Default(targetType), BindingRestrictions.Empty));

            foreach (HostArg ha in args)
            {
                Expr e = ha.ArgExpr;
                Type argType = e.HasClrType ? (e.ClrType ?? typeof(object)) : typeof(Object);

                Type t;

                switch (ha.ParamType)
                {
                    case HostArg.ParameterType.ByRef:
            #if CLR2
                        t = typeof(MSC::System.Runtime.CompilerServices.StrongBox<>).MakeGenericType(argType);
            #else
                        t = typeof(System.Runtime.CompilerServices.StrongBox<>).MakeGenericType(argType);
            #endif

                        break;
                    case HostArg.ParameterType.Standard:
                        t = argType;
                        break;
                    default:
                        throw Util.UnreachableCode();
                }
                argsPlus.Add(new DynamicMetaObject(Expression.Default(t), BindingRestrictions.Empty));
            }

            // TODO: See if we can get rid of .Default
            OverloadResolverFactory factory = ClojureContext.Default.SharedOverloadResolverFactory;
            DefaultOverloadResolver res = factory.CreateOverloadResolver(argsPlus, new CallSignature(argCount), isStatic ? CallTypes.None : CallTypes.ImplicitInstance);

            BindingTarget bt = res.ResolveOverload(methodName, methods, NarrowingLevel.None, NarrowingLevel.All);
            if (bt.Success)
                return bt.Overload.ReflectionInfo;

            return null;
        }

Same methods

Reflector::GetMatchingMethodAux ( Type targetType, object actualArgs, IList methods, string methodName, bool isStatic ) : MethodBase