summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/ModHelpers
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-12-15 21:37:08 -0500
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-12-15 21:37:08 -0500
commit21fd2d1e39a6a94758f6298c2da52cd46cffdfcd (patch)
tree2b9a0e6259acd6f723b87f20f1274dd0f7bcadcb /src/SMAPI/Framework/ModHelpers
parent356503325f4ef5ed84c359d4b56991c2a7f18b8e (diff)
downloadSMAPI-21fd2d1e39a6a94758f6298c2da52cd46cffdfcd.tar.gz
SMAPI-21fd2d1e39a6a94758f6298c2da52cd46cffdfcd.tar.bz2
SMAPI-21fd2d1e39a6a94758f6298c2da52cd46cffdfcd.zip
emit proxy classes directly to simplify crossplatform compatibility (#409)
Diffstat (limited to 'src/SMAPI/Framework/ModHelpers')
-rw-r--r--src/SMAPI/Framework/ModHelpers/ModRegistryHelper.cs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/SMAPI/Framework/ModHelpers/ModRegistryHelper.cs b/src/SMAPI/Framework/ModHelpers/ModRegistryHelper.cs
index 9574a632..ea0dbb38 100644
--- a/src/SMAPI/Framework/ModHelpers/ModRegistryHelper.cs
+++ b/src/SMAPI/Framework/ModHelpers/ModRegistryHelper.cs
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Linq;
-using ImpromptuInterface;
+using StardewModdingAPI.Framework.Reflection;
namespace StardewModdingAPI.Framework.ModHelpers
{
@@ -19,6 +19,9 @@ namespace StardewModdingAPI.Framework.ModHelpers
/// <summary>The mod IDs for APIs accessed by this instanced.</summary>
private readonly HashSet<string> AccessedModApis = new HashSet<string>();
+ /// <summary>Generates proxy classes to access mod APIs through an arbitrary interface.</summary>
+ private readonly InterfaceProxyBuilder ProxyBuilder;
+
/*********
** Public methods
@@ -26,11 +29,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="proxyBuilder">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, IMonitor monitor)
+ public ModRegistryHelper(string modID, ModRegistry registry, InterfaceProxyBuilder proxyBuilder, IMonitor monitor)
: base(modID)
{
this.Registry = registry;
+ this.ProxyBuilder = proxyBuilder;
this.Monitor = monitor;
}
@@ -94,7 +99,7 @@ namespace StardewModdingAPI.Framework.ModHelpers
// get API of type
if (api is TInterface castApi)
return castApi;
- return api.ActLike<TInterface>();
+ return this.ProxyBuilder.CreateProxy<TInterface>(api, this.ModID, uniqueID);
}
}
}