diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2016-12-04 09:43:58 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2016-12-04 09:43:58 -0500 |
commit | aaf354761f18a18b0bcb81c9bd32819bb28deac9 (patch) | |
tree | 9a47584e0cf1f419663bdd44e48d68a4abedb4bf /src/StardewModdingAPI.AssemblyRewriters/PlatformAssemblyMap.cs | |
parent | 00a3c14446b716fc32c63bccf12c79bdbee436d1 (diff) | |
parent | 48adbe249270bc863e276827aa329a765f056ae0 (diff) | |
download | SMAPI-aaf354761f18a18b0bcb81c9bd32819bb28deac9.tar.gz SMAPI-aaf354761f18a18b0bcb81c9bd32819bb28deac9.tar.bz2 SMAPI-aaf354761f18a18b0bcb81c9bd32819bb28deac9.zip |
Merge branch 'develop' into stable
Diffstat (limited to 'src/StardewModdingAPI.AssemblyRewriters/PlatformAssemblyMap.cs')
-rw-r--r-- | src/StardewModdingAPI.AssemblyRewriters/PlatformAssemblyMap.cs | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/StardewModdingAPI.AssemblyRewriters/PlatformAssemblyMap.cs b/src/StardewModdingAPI.AssemblyRewriters/PlatformAssemblyMap.cs new file mode 100644 index 00000000..f2826080 --- /dev/null +++ b/src/StardewModdingAPI.AssemblyRewriters/PlatformAssemblyMap.cs @@ -0,0 +1,57 @@ +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using Mono.Cecil; + +namespace StardewModdingAPI.AssemblyRewriters +{ + /// <summary>Metadata for mapping assemblies to the current <see cref="Platform"/>.</summary> + public class PlatformAssemblyMap + { + /********* + ** Accessors + *********/ + /**** + ** Data + ****/ + /// <summary>The target game platform.</summary> + public readonly Platform TargetPlatform; + + /// <summary>The short assembly names to remove as assembly reference, and replace with the <see cref="Targets"/>. These should be short names (like "Stardew Valley").</summary> + public readonly string[] RemoveNames; + + /// <summary>The assembly filenames to target. Equivalent types should be rewritten to use these assemblies.</summary> + + /**** + ** Metadata + ****/ + /// <summary>The assemblies to target. Equivalent types should be rewritten to use these assemblies.</summary> + public readonly Assembly[] Targets; + + /// <summary>An assembly => reference cache.</summary> + public readonly IDictionary<Assembly, AssemblyNameReference> TargetReferences; + + /// <summary>An assembly => module cache.</summary> + public readonly IDictionary<Assembly, ModuleDefinition> TargetModules; + + + /********* + ** Public methods + *********/ + /// <summary>Construct an instance.</summary> + /// <param name="targetPlatform">The target game platform.</param> + /// <param name="removeAssemblyNames">The assembly short names to remove (like <c>Stardew Valley</c>).</param> + /// <param name="targetAssemblies">The assemblies to target.</param> + public PlatformAssemblyMap(Platform targetPlatform, string[] removeAssemblyNames, Assembly[] targetAssemblies) + { + // save data + this.TargetPlatform = targetPlatform; + this.RemoveNames = removeAssemblyNames; + + // cache assembly metadata + this.Targets = targetAssemblies; + this.TargetReferences = this.Targets.ToDictionary(assembly => assembly, assembly => AssemblyNameReference.Parse(assembly.FullName)); + this.TargetModules = this.Targets.ToDictionary(assembly => assembly, assembly => ModuleDefinition.ReadModule(assembly.Modules.Single().FullyQualifiedName)); + } + } +} |