Beispiel #1
0
        static public T CreateDynamicMethodCallerDelegate <T>(this MethodInfo item)
        {
            return(item.CreateDynamicMethodDelegate <T>("Caller", delegate(MethodBase method) {
                ILParameter target = method.GetTechnicalILParameter(0);

                return new ILReturn(
                    new ILMethodInvokation(
                        target.GetILThinCast(item.GetILMethodInvokationType()),
                        item,
                        method.GetTechnicalILParameterRange(1, item.GetNumberTechnicalParameters())
                        .Convert <ILParameter, ILValue>()
                        )
                    );
            }));
        }
Beispiel #2
0
        static public T CreateDynamicEffectiveMethodInvokerDelegate <T>(this MethodInfo item)
        {
            return(item.CreateDynamicMethodDelegate <T>("Invoker", delegate(MethodBase method) {
                ILParameter target = method.GetTechnicalILParameter(0);
                ILParameter arguments = method.GetTechnicalILParameter(1);

                return new ILReturn(
                    new ILMethodInvokation(
                        target.GetILThinCast(item.GetILMethodInvokationType()),
                        item,
                        arguments.GetILExpandedParams(item)
                        )
                    );
            }));
        }
Beispiel #3
0
        static public T CreateDynamicPropertyGetterDelegate <T>(this PropertyInfo item)
        {
            MethodInfo get_method = item.GetGetMethod(true);

            return(item.CreateDynamicMethodDelegate <T>("Getter", delegate(MethodBase method) {
                ILParameter target = method.GetTechnicalILParameter(0);
                ILParameter index = method.GetTechnicalILParameter(1);

                return new ILReturn(
                    new ILMethodInvokation(
                        target.GetILThinCast(get_method.GetILMethodInvokationType()),
                        get_method,
                        index.GetILExpandedParams(item.GetIndexParameters().Convert(p => p.ParameterType))
                        )
                    );
            }));
        }