summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/Patching/PatchHelper.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-04-27 16:30:41 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-04-27 16:30:41 -0400
commitdf6e745c6b842290338317ed1d3e969ee222998c (patch)
tree4b8b28ddd7d8b9fe381bc7902f7c19187a61d4be /src/SMAPI/Framework/Patching/PatchHelper.cs
parentd0dad43e243864eb8bfdf46c853c5c7fba7c55ed (diff)
parentf44151dbb47b82250955be7c25145d1774bec705 (diff)
downloadSMAPI-df6e745c6b842290338317ed1d3e969ee222998c.tar.gz
SMAPI-df6e745c6b842290338317ed1d3e969ee222998c.tar.bz2
SMAPI-df6e745c6b842290338317ed1d3e969ee222998c.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI/Framework/Patching/PatchHelper.cs')
-rw-r--r--src/SMAPI/Framework/Patching/PatchHelper.cs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/SMAPI/Framework/Patching/PatchHelper.cs b/src/SMAPI/Framework/Patching/PatchHelper.cs
new file mode 100644
index 00000000..4cb436f0
--- /dev/null
+++ b/src/SMAPI/Framework/Patching/PatchHelper.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+
+namespace StardewModdingAPI.Framework.Patching
+{
+ /// <summary>Provides generic methods for implementing Harmony patches.</summary>
+ internal class PatchHelper
+ {
+ /*********
+ ** Fields
+ *********/
+ /// <summary>The interception keys currently being intercepted.</summary>
+ private static readonly HashSet<string> InterceptingKeys = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Track a method that will be intercepted.</summary>
+ /// <param name="key">The intercept key.</param>
+ /// <returns>Returns false if the method was already marked for interception, else true.</returns>
+ public static bool StartIntercept(string key)
+ {
+ return PatchHelper.InterceptingKeys.Add(key);
+ }
+
+ /// <summary>Track a method as no longer being intercepted.</summary>
+ /// <param name="key">The intercept key.</param>
+ public static void StopIntercept(string key)
+ {
+ PatchHelper.InterceptingKeys.Remove(key);
+ }
+ }
+}