public PatchProcessor(HarmonyInstance instance, List <MethodBase> originals, HarmonyMethod prefix = null, HarmonyMethod postfix = null, HarmonyMethod transpiler = null) { patchProcessors = new List <HarmonyLib.PatchProcessor>(); foreach (var method in originals) { patchProcessors.Add(new HarmonyLib.PatchProcessor(instance.instance, method)); } this.instance = instance; this.originals = originals; if (prefix?.method != null) { patchProcessors.Do(p => p.AddPrefix(prefix.ToHarmony20())); } if (postfix?.method != null) { patchProcessors.Do(p => p.AddPostfix(postfix.ToHarmony20())); } if (transpiler?.method != null) { patchProcessors.Do(p => p.AddTranspiler(transpiler.ToHarmony20())); } this.prefix = prefix ?? new HarmonyMethod(null); this.postfix = postfix ?? new HarmonyMethod(null); this.transpiler = transpiler ?? new HarmonyMethod(null); }
public PatchProcessor(HarmonyInstance instance, Type type, HarmonyMethod attributes) { this.instance = instance; container = type; containerAttributes = attributes ?? new HarmonyMethod(null); prefix = containerAttributes.Clone(); postfix = containerAttributes.Clone(); transpiler = containerAttributes.Clone(); PrepareType(); patchProcessors = new List <HarmonyLib.PatchProcessor>(); foreach (var method in originals) { patchProcessors.Add(new HarmonyLib.PatchProcessor(instance.instance, method)); } if (prefix?.method != null) { patchProcessors.Do(p => p.AddPrefix(prefix.ToHarmony20())); } if (postfix?.method != null) { patchProcessors.Do(p => p.AddPostfix(postfix.ToHarmony20())); } if (transpiler?.method != null) { patchProcessors.Do(p => p.AddTranspiler(transpiler.ToHarmony20())); } }