diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-02-25 23:40:52 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-02-25 23:40:52 -0500 |
commit | 0f987c0578b69d57c01502bc44b43b4e9619e658 (patch) | |
tree | 8753e87737990929864d931c725ef8eefefaaf33 /src/SMAPI/Framework/ModHelpers/ModRegistryHelper.cs | |
parent | 512c2b9fb761838a852fb4c8fe8dff40bab5f31e (diff) | |
download | SMAPI-0f987c0578b69d57c01502bc44b43b4e9619e658.tar.gz SMAPI-0f987c0578b69d57c01502bc44b43b4e9619e658.tar.bz2 SMAPI-0f987c0578b69d57c01502bc44b43b4e9619e658.zip |
restore InterfaceProxyFactory to encapsulate Pintail (#830)
Diffstat (limited to 'src/SMAPI/Framework/ModHelpers/ModRegistryHelper.cs')
-rw-r--r-- | src/SMAPI/Framework/ModHelpers/ModRegistryHelper.cs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/SMAPI/Framework/ModHelpers/ModRegistryHelper.cs b/src/SMAPI/Framework/ModHelpers/ModRegistryHelper.cs index 93ea6028..95eb03f3 100644 --- a/src/SMAPI/Framework/ModHelpers/ModRegistryHelper.cs +++ b/src/SMAPI/Framework/ModHelpers/ModRegistryHelper.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using Nanoray.Pintail; using StardewModdingAPI.Framework.Reflection; namespace StardewModdingAPI.Framework.ModHelpers @@ -17,10 +16,10 @@ namespace StardewModdingAPI.Framework.ModHelpers private readonly IMonitor Monitor; /// <summary>The mod IDs for APIs accessed by this instanced.</summary> - private readonly HashSet<string> AccessedModApis = new HashSet<string>(); + private readonly HashSet<string> AccessedModApis = new(); /// <summary>Generates proxy classes to access mod APIs through an arbitrary interface.</summary> - private readonly IProxyManager<string> ProxyManager; + private readonly InterfaceProxyFactory ProxyFactory; /********* @@ -29,13 +28,13 @@ namespace StardewModdingAPI.Framework.ModHelpers /// <summary>Construct an instance.</summary> /// <param name="modID">The unique ID of the relevant mod.</param> /// <param name="registry">The underlying mod registry.</param> - /// <param name="proxyManager">Generates proxy classes to access mod APIs through an arbitrary interface.</param> + /// <param name="proxyFactory">Generates proxy classes to access mod APIs through an arbitrary interface.</param> /// <param name="monitor">Encapsulates monitoring and logging for the mod.</param> - public ModRegistryHelper(string modID, ModRegistry registry, IProxyManager<string> proxyManager, IMonitor monitor) + public ModRegistryHelper(string modID, ModRegistry registry, InterfaceProxyFactory proxyFactory, IMonitor monitor) : base(modID) { this.Registry = registry; - this.ProxyManager = proxyManager; + this.ProxyFactory = proxyFactory; this.Monitor = monitor; } @@ -95,9 +94,9 @@ namespace StardewModdingAPI.Framework.ModHelpers } // get API of type - if (api is TInterface castApi) - return castApi; - return this.ProxyManager.ObtainProxy<string, TInterface>(api, this.ModID, uniqueID); + return api is TInterface castApi + ? castApi + : this.ProxyFactory.CreateProxy<TInterface>(api, sourceModID: this.ModID, targetModID: uniqueID); } } } |