Ejemplo n.º 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>()
                        )
                    );
            }));
        }
Ejemplo n.º 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)
                        )
                    );
            }));
        }
Ejemplo n.º 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))
                        )
                    );
            }));
        }