CM3D2.MaidFiddler.Sybaris.Patcher.MaidFiddlerPatcher.PatchFuncEnumBool C# (CSharp) Method

PatchFuncEnumBool() private static method

private static PatchFuncEnumBool ( MaidChangeType tag, Mono.Cecil.MethodDefinition target, Mono.Cecil.MethodDefinition hook ) : void
tag MaidChangeType
target Mono.Cecil.MethodDefinition
hook Mono.Cecil.MethodDefinition
return void
        private static void PatchFuncEnumBool(MaidChangeType tag, MethodDefinition target, MethodDefinition hook)
        {
            MethodReference hookRef = target.Module.Import(hook);
            FieldReference maidFieldRef = target.Module.Import(target.DeclaringType.GetField("maid_"));

            Instruction start = target.Body.Instructions[0];
            ILProcessor il = target.Body.GetILProcessor();

            il.InsertBefore(start, il.Create(OpCodes.Ldc_I4, (int) tag));
            il.InsertBefore(start, il.Create(OpCodes.Ldarg_0));
            il.InsertBefore(start, il.Create(OpCodes.Ldflda, maidFieldRef));
            il.InsertBefore(start, il.Create(OpCodes.Ldarg_1));
            il.InsertBefore(start, il.Create(OpCodes.Ldarg_2));
            il.InsertBefore(start, il.Create(OpCodes.Call, hookRef));
        }