using System.IO; namespace StardewModdingAPI.Framework.AssemblyRewriting { /// Represents cached metadata for a rewritten assembly. internal class CacheEntry { /********* ** Accessors *********/ /// The MD5 hash for the original assembly. public readonly string Hash; /// The SMAPI version used to rewrite the assembly. public readonly string ApiVersion; /// Whether to use the cached assembly instead of the original assembly. public readonly bool UseCachedAssembly; /********* ** Public methods *********/ /// Construct an instance. /// The MD5 hash for the original assembly. /// The SMAPI version used to rewrite the assembly. /// Whether to use the cached assembly instead of the original assembly. public CacheEntry(string hash, string apiVersion, bool useCachedAssembly) { this.Hash = hash; this.ApiVersion = apiVersion; this.UseCachedAssembly = useCachedAssembly; } /// Get whether the cache entry is up-to-date for the given assembly hash. /// The paths for the cached assembly. /// The MD5 hash of the original assembly. /// The current SMAPI version. public bool IsUpToDate(CachePaths paths, string hash, Version currentVersion) { return hash == this.Hash && this.ApiVersion == currentVersion.ToString() && (!this.UseCachedAssembly || File.Exists(paths.Assembly)); } } }