using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Mono.Cecil;
namespace StardewModdingAPI.AssemblyRewriters
{
/// Metadata for mapping assemblies to the current .
public class PlatformAssemblyMap
{
/*********
** Accessors
*********/
/****
** Data
****/
/// The target game platform.
public readonly Platform TargetPlatform;
/// The short assembly names to remove as assembly reference, and replace with the . These should be short names (like "Stardew Valley").
public readonly string[] RemoveNames;
/// The assembly filenames to target. Equivalent types should be rewritten to use these assemblies.
/****
** Metadata
****/
/// The assemblies to target. Equivalent types should be rewritten to use these assemblies.
public readonly Assembly[] Targets;
/// An assembly => reference cache.
public readonly IDictionary TargetReferences;
/// An assembly => module cache.
public readonly IDictionary TargetModules;
/*********
** Public methods
*********/
/// Construct an instance.
/// The target game platform.
/// The assembly short names to remove (like Stardew Valley).
/// The assemblies to target.
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));
}
}
}