diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2020-04-15 18:06:37 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2020-04-15 18:06:37 -0400 |
commit | 97821362daeaa3dd34e3728680760d44043825be (patch) | |
tree | 7bc5416cc1c723376b80ea987b94b00fde31322c /src/SMAPI/Framework/Patching/PatchHelper.cs | |
parent | 5f73d47fb9dfe7ac2733a0a5fe57cf96639594f9 (diff) | |
download | SMAPI-97821362daeaa3dd34e3728680760d44043825be.tar.gz SMAPI-97821362daeaa3dd34e3728680760d44043825be.tar.bz2 SMAPI-97821362daeaa3dd34e3728680760d44043825be.zip |
prevent object.loadDisplayName errors due to invalid/missing item data
Diffstat (limited to 'src/SMAPI/Framework/Patching/PatchHelper.cs')
-rw-r--r-- | src/SMAPI/Framework/Patching/PatchHelper.cs | 34 |
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); + } + } +} |