예제 #1
0
        static public IteratorGetter CreateIteratorGetter(this Type item, Type child_type, IEnumerable <PropInfoEX> iterator_targets)
        {
            return(item.CreateDynamicMethodDelegate <IteratorGetter>("Iterator_" + item.Name + "<" + child_type.Name + ">", delegate(MethodBase method) {
                ILParameter this_parameter = method.GetTechnicalILParameter(0);

                return new ILReturn(
                    new ILIteratorSlew(iterator_targets.Convert(t => (ILValue) new ILProp(this_parameter, t)))
                    );
            }));
        }
예제 #2
0
        static public T CreateDynamicConstructorInvokerDelegate <T>(this ConstructorInfo item)
        {
            return(item.CreateDynamicMethodDelegate <T>("Invoker", delegate(MethodBase method) {
                ILParameter arguments = method.GetTechnicalILParameter(0);

                return new ILReturn(
                    new ILNew(
                        item,
                        arguments.GetILExpandedParams(item)
                        )
                    );
            }));
        }
예제 #3
0
        static public T CreateDynamicTechnicalMethodInvokerDelegate <T>(this MethodInfo item)
        {
            if (item.IsExtensionMethod())
            {
                return(item.CreateDynamicMethodDelegate <T>("TechnicalInvoker", delegate(MethodBase method) {
                    ILParameter target = method.GetTechnicalILParameter(0);
                    ILParameter arguments = method.GetTechnicalILParameter(1);

                    return item.GetStaticILMethodInvokation(arguments.GetILExpandedParams(item));
                }));
            }

            return(item.CreateDynamicEffectiveMethodInvokerDelegate <T>());
        }
예제 #4
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>()
                        )
                    );
            }));
        }
예제 #5
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)
                        )
                    );
            }));
        }
예제 #6
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))
                        )
                    );
            }));
        }