示例#1
0
        private static DelegateMethod WrapMethodInfo(MethodBase methodInfo, Type[] parameterTypes, Type[] genericArguments)
        {
            Method method = CreateMethod(methodInfo, parameterTypes);

            DelegateMethod methodWrapper = new DelegateMethod(methodInfo, parameterTypes, genericArguments, method);

            DelegateMethodHandleCache.Add(methodWrapper.MethodHandle, methodWrapper);

            List <DelegateMethod> methodList;

            if (!DelegateMethodCache.TryGetValue(methodWrapper.MethodName, out methodList))
            {
                methodList = new List <DelegateMethod>();
                DelegateMethodCache.Add(methodWrapper.MethodName, methodList);
            }
            methodList.Add(methodWrapper);
            return(methodWrapper);
        }
示例#2
0
        private static DelegateMethod FindDelegateMethod(Type targetType, string methodName, Type[] parametersTypes, Type[] genericArguments)
        {
            Debug.Assert(null != targetType, "null targetType");
            Debug.Assert(!String.IsNullOrEmpty(methodName), "empty methodName");

            List <DelegateMethod> methodList;

            if (DelegateMethodCache.TryGetValue(methodName, out methodList))
            {
                foreach (DelegateMethod member in methodList)
                {
                    if (member.AreEqual(targetType, parametersTypes, genericArguments))
                    {
                        return(member);
                    }
                }
            }
            return(null);
        }