From 948c800a98f00b1bdcfd05ee6228e3423f9eb465 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 30 Jul 2021 00:54:15 -0400 Subject: migrate to the new Harmony patch pattern used in my mods That improves validation and error-handling. --- src/SMAPI/Framework/Patching/GamePatcher.cs | 45 ----------------------------- 1 file changed, 45 deletions(-) delete mode 100644 src/SMAPI/Framework/Patching/GamePatcher.cs (limited to 'src/SMAPI/Framework/Patching/GamePatcher.cs') diff --git a/src/SMAPI/Framework/Patching/GamePatcher.cs b/src/SMAPI/Framework/Patching/GamePatcher.cs deleted file mode 100644 index 3ce22ee9..00000000 --- a/src/SMAPI/Framework/Patching/GamePatcher.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using HarmonyLib; - -namespace StardewModdingAPI.Framework.Patching -{ - /// Encapsulates applying Harmony patches to the game. - internal class GamePatcher - { - /********* - ** Fields - *********/ - /// Encapsulates monitoring and logging. - private readonly IMonitor Monitor; - - - /********* - ** Public methods - *********/ - /// Construct an instance. - /// Encapsulates monitoring and logging. - public GamePatcher(IMonitor monitor) - { - this.Monitor = monitor; - } - - /// Apply all loaded patches to the game. - /// The patches to apply. - public void Apply(params IHarmonyPatch[] patches) - { - Harmony harmony = new Harmony("SMAPI"); - foreach (IHarmonyPatch patch in patches) - { - try - { - patch.Apply(harmony); - } - catch (Exception ex) - { - this.Monitor.Log($"Couldn't apply runtime patch '{patch.GetType().Name}' to the game. Some SMAPI features may not work correctly. See log file for details.", LogLevel.Error); - this.Monitor.Log(ex.GetLogSummary(), LogLevel.Trace); - } - } - } - } -} -- cgit