CK.Reflection.ILGeneratorExtension.CreateObjectArrayFromInstanceParameters C# (CSharp) Method

CreateObjectArrayFromInstanceParameters() public static method

Emits the IL to create a new array (OpCodes.Newarr) of objects and fills it with the actual arguments of the method (parameters are boxed if needed) skipping the very first one: this must be used only inside a method with System.Reflection.CallingConventions.HasThis set.
public static CreateObjectArrayFromInstanceParameters ( this g, LocalBuilder array, Type parameters ) : void
g this This object.
array System.Reflection.Emit.LocalBuilder The local variable.
parameters System.Type Type of the method parameters.
return void
        public static void CreateObjectArrayFromInstanceParameters( this ILGenerator g, LocalBuilder array, Type[] parameters )
        {
            g.LdInt32( parameters.Length );
            g.Emit( OpCodes.Newarr, typeof( object ) );
            g.StLoc( array );
            for( int i = 0; i < parameters.Length; ++i )
            {
                g.LdLoc( array );
                g.LdInt32( i );
                g.LdArgBox( i + 1, parameters[i] );
                g.Emit( OpCodes.Stelem_Ref );
            }
        }