Пример #1
0
        private static DelegateMethod WrapMethod(MethodBase methodInfo, Type[] parameterTypes, Type[] genericArguments)
        {
            DelegateMethod methodWrapper;

            if (!DelegateMethodHandleCache.TryGetValue(new MethodDef(methodInfo.MethodHandle, methodInfo.DeclaringType.TypeHandle), out methodWrapper))
            {
                methodWrapper = WrapMethodInfo(methodInfo, parameterTypes, genericArguments);
            }
            return(methodWrapper);
        }
Пример #2
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);
        }
Пример #3
0
        private static DelegateMethod WrapMethod(MethodInfo methodInfo)
        {
            DelegateMethod methodWrapper;

            if (!DelegateMethodHandleCache.TryGetValue(new MethodDef(methodInfo.MethodHandle, methodInfo.DeclaringType.TypeHandle), out methodWrapper))
            {
                ParameterInfo[] parameterInfo  = methodInfo.GetParameters();
                Type[]          parameterTypes = ((0 < parameterInfo.Length) ? new Type[parameterInfo.Length] : Type.EmptyTypes);
                for (int i = 0; i < parameterInfo.Length; ++i)
                {
                    parameterTypes[i] = parameterInfo[i].ParameterType;
                }
                Type[] genericArguments = ((methodInfo.IsGenericMethod) ? methodInfo.GetGenericArguments() : Type.EmptyTypes);

                methodWrapper = WrapMethodInfo(methodInfo, parameterTypes, genericArguments);
            }
            return(methodWrapper);
        }