static void ApplyPatch(string owner, MethodBase target, HarmonyMethod prefix = null, HarmonyMethod postfix = null, HarmonyMethod transpiler = null) { var instance = HarmonyInstance.Create(owner); var processor = new Harmony.PatchProcessor(instance, new List <MethodBase> { target }, prefix: prefix, postfix: postfix, transpiler: transpiler); processor.Patch(); }
public void TestMultiple() { var targetMethods = new List <MethodBase>() { AccessTools.Method(typeof(PatchProcessorClass1), nameof(PatchProcessorClass1.TestA)), AccessTools.Method(typeof(PatchProcessorClass1), nameof(PatchProcessorClass1.TestB)) }; var postfix = new HarmonyMethod(typeof(PatchProcessorPatchClass1), nameof(PatchProcessorPatchClass1.Postfix)); var harmony = HarmonyInstance.Create("test"); var processor = new Harmony.PatchProcessor(harmony, targetMethods, postfix: postfix); processor.Patch(); Assert.AreEqual("Patched", PatchProcessorClass1.TestA(), "Test A"); Assert.AreEqual("Patched", PatchProcessorClass1.TestB(), "Test B"); }
public void Patch(MethodBase original, HarmonyMethod prefix, HarmonyMethod postfix, HarmonyMethod transpiler = null) { var processor = new PatchProcessor(this, original, prefix, postfix, transpiler); processor.Patch(); }
// public Patches IsPatched(MethodBase method) { return(PatchProcessor.IsPatched(method)); }
public Patches GetPatchInfo(MethodBase method) { return(PatchProcessor.GetPatchInfo(method)); }