Example #1
0
        public static ILGenerator PushArgumentsOntoStack(this ILGenerator generator, ParameterInfo[] parameters)
        {
            for (int i = 0; i < parameters.Length; i++)
            {
                generator.AndPushArgument1OntoStack()
                .AndPushInt32AsInt32OntoStack(i)
                .AndPushElementFromArrayAtIndexOnStackOntoStack();

                generator.AndUnboxValueTypeArgument(parameters[i].ParameterType);
            }
            return(generator);
        }
Example #2
0
        public static Label EnsureCorrectNumberOfArgumentsHaveBeenSupplied(this ILGenerator generator, ParameterInfo[] parameters)
        {
            Label argsGood = generator.DefineLabel();

            generator
            .AndPushArgument1OntoStack()
            .AndPushArrayLengthOntoStack()
            .AndPushInt32AsInt32OntoStack(parameters.Length)
            .AndGotoLabelIfTop2ItemsOnStackAreEqual(argsGood);

            return(argsGood);
        }