diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2016-12-12 11:52:34 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2016-12-12 11:52:34 -0500 |
commit | 28e2695a19f7babf35d177367840a82b798beb55 (patch) | |
tree | 591b2badd77a7c9c0c36b8e09abdb6a323513307 /src/StardewModdingAPI/Framework/AssemblyRewriting/CacheEntry.cs | |
parent | aaf354761f18a18b0bcb81c9bd32819bb28deac9 (diff) | |
parent | a3376e2a6257c01c52a3c64c4f5f1f8de9a9c906 (diff) | |
download | SMAPI-28e2695a19f7babf35d177367840a82b798beb55.tar.gz SMAPI-28e2695a19f7babf35d177367840a82b798beb55.tar.bz2 SMAPI-28e2695a19f7babf35d177367840a82b798beb55.zip |
Merge branch 'develop' into stable
Diffstat (limited to 'src/StardewModdingAPI/Framework/AssemblyRewriting/CacheEntry.cs')
-rw-r--r-- | src/StardewModdingAPI/Framework/AssemblyRewriting/CacheEntry.cs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/StardewModdingAPI/Framework/AssemblyRewriting/CacheEntry.cs b/src/StardewModdingAPI/Framework/AssemblyRewriting/CacheEntry.cs new file mode 100644 index 00000000..3dfbc78c --- /dev/null +++ b/src/StardewModdingAPI/Framework/AssemblyRewriting/CacheEntry.cs @@ -0,0 +1,46 @@ +using System.IO; + +namespace StardewModdingAPI.Framework.AssemblyRewriting +{ + /// <summary>Represents cached metadata for a rewritten assembly.</summary> + internal class CacheEntry + { + /********* + ** Accessors + *********/ + /// <summary>The MD5 hash for the original assembly.</summary> + public readonly string Hash; + + /// <summary>The SMAPI version used to rewrite the assembly.</summary> + public readonly string ApiVersion; + + /// <summary>Whether to use the cached assembly instead of the original assembly.</summary> + public readonly bool UseCachedAssembly; + + + /********* + ** Public methods + *********/ + /// <summary>Construct an instance.</summary> + /// <param name="hash">The MD5 hash for the original assembly.</param> + /// <param name="apiVersion">The SMAPI version used to rewrite the assembly.</param> + /// <param name="useCachedAssembly">Whether to use the cached assembly instead of the original assembly.</param> + public CacheEntry(string hash, string apiVersion, bool useCachedAssembly) + { + this.Hash = hash; + this.ApiVersion = apiVersion; + this.UseCachedAssembly = useCachedAssembly; + } + + /// <summary>Get whether the cache entry is up-to-date for the given assembly hash.</summary> + /// <param name="paths">The paths for the cached assembly.</param> + /// <param name="hash">The MD5 hash of the original assembly.</param> + /// <param name="currentVersion">The current SMAPI version.</param> + public bool IsUpToDate(CachePaths paths, string hash, Version currentVersion) + { + return hash == this.Hash + && this.ApiVersion == currentVersion.ToString() + && (!this.UseCachedAssembly || File.Exists(paths.Assembly)); + } + } +}
\ No newline at end of file |