summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/ModHelpers/ModRegistryHelper.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-02-25 23:40:52 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-02-25 23:40:52 -0500
commit0f987c0578b69d57c01502bc44b43b4e9619e658 (patch)
tree8753e87737990929864d931c725ef8eefefaaf33 /src/SMAPI/Framework/ModHelpers/ModRegistryHelper.cs
parent512c2b9fb761838a852fb4c8fe8dff40bab5f31e (diff)
downloadSMAPI-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.cs17
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);
}
}
}