diff --git a/Harmony/Public/HarmonyMethod.cs b/Harmony/Public/HarmonyMethod.cs
index 4ba83863..a9d60901 100644
--- a/Harmony/Public/HarmonyMethod.cs
+++ b/Harmony/Public/HarmonyMethod.cs
@@ -86,6 +86,13 @@ public HarmonyMethod(MethodInfo method)
ImportMethod(method);
}
+ /// Creates a patch from a given method
+ /// The original method
+ ///
+ public HarmonyMethod(Delegate @delegate)
+ : this(@delegate.Method)
+ { }
+
/// Creates a patch from a given method
/// The original method
/// The patch
@@ -104,6 +111,17 @@ public HarmonyMethod(MethodInfo method, int priority = -1, string[] before = nul
this.debug = debug;
}
+ /// Creates a patch from a given method
+ /// The original method
+ /// The patch
+ /// A list of harmony IDs that should come after this patch
+ /// A list of harmony IDs that should come before this patch
+ /// Set to true to generate debug output
+ ///
+ public HarmonyMethod(Delegate @delegate, int priority = -1, string[] before = null, string[] after = null, bool? debug = null)
+ : this(@delegate.Method, priority, before, after, debug)
+ { }
+
/// Creates a patch from a given method
/// The patch class/type
/// The patch method name
@@ -177,6 +195,22 @@ internal string Description()
var aName = argumentTypes is object ? argumentTypes.Description() : "undefined";
return $"(class={cName}, methodname={mName}, type={tName}, args={aName})";
}
+
+ /// Creates a patch from a given method
+ /// The original method
+ ///
+ public static implicit operator HarmonyMethod(MethodInfo method)
+ {
+ return new HarmonyMethod(method);
+ }
+
+ /// Creates a patch from a given method
+ /// The original method
+ ///
+ public static implicit operator HarmonyMethod(Delegate @delegate)
+ {
+ return new HarmonyMethod(@delegate);
+ }
}
/// Annotation extensions