summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2016-11-28 20:51:57 -0500
committerJesse Plamondon-Willard <github@jplamondonw.com>2016-11-28 20:51:57 -0500
commitf3675aa466e429810fd4254a0413403e203c942e (patch)
tree8a88bf93bd5021e244ff9c68536ff22f3b67e8ea /src
parentf7b8879011873fa8f7a3d5dd7db27254bfc90469 (diff)
downloadSMAPI-f3675aa466e429810fd4254a0413403e203c942e.tar.gz
SMAPI-f3675aa466e429810fd4254a0413403e203c942e.tar.bz2
SMAPI-f3675aa466e429810fd4254a0413403e203c942e.zip
move assembly map into constants (#166)
Diffstat (limited to 'src')
-rw-r--r--src/StardewModdingAPI/Constants.cs52
-rw-r--r--src/StardewModdingAPI/Framework/ModAssemblyLoader.cs48
2 files changed, 53 insertions, 47 deletions
diff --git a/src/StardewModdingAPI/Constants.cs b/src/StardewModdingAPI/Constants.cs
index 05e410ab..66eb1336 100644
--- a/src/StardewModdingAPI/Constants.cs
+++ b/src/StardewModdingAPI/Constants.cs
@@ -2,6 +2,8 @@
using System.IO;
using System.Linq;
using System.Reflection;
+using StardewModdingAPI.Framework;
+using StardewModdingAPI.Framework.AssemblyRewriting;
using StardewValley;
namespace StardewModdingAPI
@@ -63,6 +65,56 @@ namespace StardewModdingAPI
/*********
+ ** Internal field
+ *********/
+ /// <summary>Get metadata for mapping assemblies to the current platform.</summary>
+ /// <param name="targetPlatform">The target game platform.</param>
+ internal static PlatformAssemblyMap GetAssemblyMap(Platform targetPlatform)
+ {
+ // get assembly changes needed for platform
+ string[] removeAssemblyReferences;
+ Assembly[] targetAssemblies;
+ switch (targetPlatform)
+ {
+ case Platform.Mono:
+ removeAssemblyReferences = new[]
+ {
+ "Stardew Valley",
+ "Microsoft.Xna.Framework",
+ "Microsoft.Xna.Framework.Game",
+ "Microsoft.Xna.Framework.Graphics"
+ };
+ targetAssemblies = new[]
+ {
+ typeof(StardewValley.Game1).Assembly,
+ typeof(Microsoft.Xna.Framework.Vector2).Assembly
+ };
+ break;
+
+ case Platform.Windows:
+ removeAssemblyReferences = new[]
+ {
+ "StardewValley",
+ "MonoGame.Framework"
+ };
+ targetAssemblies = new[]
+ {
+ typeof(StardewValley.Game1).Assembly,
+ typeof(Microsoft.Xna.Framework.Vector2).Assembly,
+ typeof(Microsoft.Xna.Framework.Game).Assembly,
+ typeof(Microsoft.Xna.Framework.Graphics.SpriteBatch).Assembly
+ };
+ break;
+
+ default:
+ throw new InvalidOperationException($"Unknown target platform '{targetPlatform}'.");
+ }
+
+ return new PlatformAssemblyMap(targetPlatform, removeAssemblyReferences, targetAssemblies);
+ }
+
+
+ /*********
** Private field
*********/
/// <summary>Get the name of a save directory for the current player.</summary>
diff --git a/src/StardewModdingAPI/Framework/ModAssemblyLoader.cs b/src/StardewModdingAPI/Framework/ModAssemblyLoader.cs
index 3d08ec64..b6d98bde 100644
--- a/src/StardewModdingAPI/Framework/ModAssemblyLoader.cs
+++ b/src/StardewModdingAPI/Framework/ModAssemblyLoader.cs
@@ -38,7 +38,7 @@ namespace StardewModdingAPI.Framework
{
this.CacheDirPath = cacheDirPath;
this.Monitor = monitor;
- this.AssemblyMap = this.GetAssemblyMap(targetPlatform);
+ this.AssemblyMap = Constants.GetAssemblyMap(targetPlatform);
this.AssemblyTypeRewriter = new AssemblyTypeRewriter(this.AssemblyMap, monitor);
}
@@ -123,51 +123,5 @@ namespace StardewModdingAPI.Framework
string cacheHashPath = Path.Combine(dirPath, $"{key}.hash");
return new CachePaths(dirPath, cacheAssemblyPath, cacheHashPath);
}
-
- /// <summary>Get metadata for mapping assemblies to the current platform.</summary>
- /// <param name="targetPlatform">The target game platform.</param>
- private PlatformAssemblyMap GetAssemblyMap(Platform targetPlatform)
- {
- // get assembly changes needed for platform
- string[] removeAssemblyReferences;
- Assembly[] targetAssemblies;
- switch (targetPlatform)
- {
- case Platform.Mono:
- removeAssemblyReferences = new[]
- {
- "Stardew Valley",
- "Microsoft.Xna.Framework",
- "Microsoft.Xna.Framework.Game",
- "Microsoft.Xna.Framework.Graphics"
- };
- targetAssemblies = new[]
- {
- typeof(StardewValley.Game1).Assembly,
- typeof(Microsoft.Xna.Framework.Vector2).Assembly
- };
- break;
-
- case Platform.Windows:
- removeAssemblyReferences = new[]
- {
- "StardewValley",
- "MonoGame.Framework"
- };
- targetAssemblies = new[]
- {
- typeof(StardewValley.Game1).Assembly,
- typeof(Microsoft.Xna.Framework.Vector2).Assembly,
- typeof(Microsoft.Xna.Framework.Game).Assembly,
- typeof(Microsoft.Xna.Framework.Graphics.SpriteBatch).Assembly
- };
- break;
-
- default:
- throw new InvalidOperationException($"Unknown target platform '{targetPlatform}'.");
- }
-
- return new PlatformAssemblyMap(targetPlatform, removeAssemblyReferences, targetAssemblies);
- }
}
}