diff options
Diffstat (limited to 'src/StardewModdingAPI/Framework/AssemblyDefinitionResolver.cs')
-rw-r--r-- | src/StardewModdingAPI/Framework/AssemblyDefinitionResolver.cs | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/src/StardewModdingAPI/Framework/AssemblyDefinitionResolver.cs b/src/StardewModdingAPI/Framework/AssemblyDefinitionResolver.cs deleted file mode 100644 index b4e69fcd..00000000 --- a/src/StardewModdingAPI/Framework/AssemblyDefinitionResolver.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System.Collections.Generic; -using Mono.Cecil; - -namespace StardewModdingAPI.Framework -{ - /// <summary>A minimal assembly definition resolver which resolves references to known assemblies.</summary> - internal class AssemblyDefinitionResolver : DefaultAssemblyResolver - { - /********* - ** Properties - *********/ - /// <summary>The known assemblies.</summary> - private readonly IDictionary<string, AssemblyDefinition> Loaded = new Dictionary<string, AssemblyDefinition>(); - - - /********* - ** Public methods - *********/ - /// <summary>Add known assemblies to the resolver.</summary> - /// <param name="assemblies">The known assemblies.</param> - public void Add(params AssemblyDefinition[] assemblies) - { - foreach (AssemblyDefinition assembly in assemblies) - { - this.Loaded[assembly.Name.Name] = assembly; - this.Loaded[assembly.Name.FullName] = assembly; - } - } - - /// <summary>Resolve an assembly reference.</summary> - /// <param name="name">The assembly name.</param> - public override AssemblyDefinition Resolve(AssemblyNameReference name) => this.ResolveName(name.Name) ?? base.Resolve(name); - - /// <summary>Resolve an assembly reference.</summary> - /// <param name="name">The assembly name.</param> - /// <param name="parameters">The assembly reader parameters.</param> - public override AssemblyDefinition Resolve(AssemblyNameReference name, ReaderParameters parameters) => this.ResolveName(name.Name) ?? base.Resolve(name, parameters); - - /// <summary>Resolve an assembly reference.</summary> - /// <param name="fullName">The assembly full name (including version, etc).</param> - public override AssemblyDefinition Resolve(string fullName) => this.ResolveName(fullName) ?? base.Resolve(fullName); - - /// <summary>Resolve an assembly reference.</summary> - /// <param name="fullName">The assembly full name (including version, etc).</param> - /// <param name="parameters">The assembly reader parameters.</param> - public override AssemblyDefinition Resolve(string fullName, ReaderParameters parameters) => this.ResolveName(fullName) ?? base.Resolve(fullName, parameters); - - - /********* - ** Private methods - *********/ - /// <summary>Resolve a known assembly definition based on its short or full name.</summary> - /// <param name="name">The assembly's short or full name.</param> - private AssemblyDefinition ResolveName(string name) - { - return this.Loaded.ContainsKey(name) - ? this.Loaded[name] - : null; - } - } -} |