Esempio n. 1
0
        static VarArgsInvoke()
        {
            if (delType.BaseType != typeof(MulticastDelegate))
            {
                throw new TypeLoadException("TDelegate must be a delegate type.");
            }

            Invoke = new InvokeCache();
            MethodInfo invoke = delType.GetMethod("Invoke");

            argTypes = invoke.GetParameters().Select(p => p.ParameterType).ToArray();
            Type last = argTypes[argTypes.Length - 1];

            retType = invoke.ReturnType;
            if (last == typeof(MethodInfo))
            {
                passmethod = true;
                argTypes[argTypes.Length - 1] = typeof(IntPtr);
                dynType = ReflectionTools.GetDelegateType(retType, argTypes);
            }
            else if (last != typeof(IntPtr))
            {
                throw new TypeLoadException("Last parameter of the delegate type must be System.IntPtr or System.Reflection.MethodInfo.");
            }
            else
            {
                dynType = delType;
            }
        }
Esempio n. 2
0
 public Type GetDelegateType()
 {
     return(ReflectionTools.GetDelegateType(ReturnType, ParameterTypes));
 }