Inject() public method

Inject the call of the injection method into the target.
public Inject ( Instruction startCode, int token, InjectDirection direction = InjectDirection.Before ) : void
startCode Mono.Cecil.Cil.Instruction The instruction from which to start injecting.
token int /// If is specified, the value of this parameter will be passed as a /// parameter to the injection method. ///
direction InjectDirection The direction in which to insert the call: either above the start code or below it.
return void
        /// <summary>
        ///     Inject a hook call into this method.
        /// </summary>
        /// <param name="method">This method that is used as a target.</param>
        /// <param name="injectionMethod">The method the call of which to inject.</param>
        /// <param name="codeOffset">
        ///     The index of the instruction from which to start injecting. If positive, will count from the
        ///     beginning of the method. If negative, will count from the end. For instance, -1 is the method's last instruction
        ///     and 0 is the first.
        /// </param>
        /// <param name="tag">
        ///     If <see cref="InjectFlags.PassTag" /> is specified, the value of this parameter will be passed as a
        ///     parameter to the injection method.
        /// </param>
        /// <param name="flags">Injection flags that specify what values to pass to the injection method and how to inject it.</param>
        /// <param name="dir">The direction in which to insert the call: either above the start code or below it.</param>
        /// <param name="localsID">
        ///     An array of indicies of local variables to pass to the injection method. Used only if
        ///     <see cref="InjectFlags.PassLocals" /> is specified, otherwise ignored.
        /// </param>
        /// <param name="typeFields">
        ///     An array of class fields from the type the target lies in to pass to the injection method.
        ///     Used only if <see cref="InjectFlags.PassFields" /> is specified, otherwise ignored.
        /// </param>
        public static void InjectWith(this MethodDefinition method,
                                      MethodDefinition injectionMethod,
                                      int codeOffset               = 0,
                                      object tag                   = null,
                                      InjectFlags flags            = InjectFlags.None,
                                      InjectDirection dir          = InjectDirection.Before,
                                      int[] localsID               = null,
                                      FieldDefinition[] typeFields = null)
        {
            InjectionDefinition id = new InjectionDefinition(method, injectionMethod, flags, localsID, typeFields);

            id.Inject(codeOffset, tag, dir);
        }