diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-04-05 14:55:46 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-04-05 14:55:46 -0400 |
commit | dbb9bd84306830456032778fc11fb9a34dd140c7 (patch) | |
tree | 0219cab065bfffbbbb9b048b6a30044f510be2c5 /src/StardewModdingAPI/Framework/ModRegistry.cs | |
parent | 9c9833c9086b758589dafee10243e3bf47e12d73 (diff) | |
parent | 4675da0600edf6781cd740549ad0a175b606fc1e (diff) | |
download | SMAPI-dbb9bd84306830456032778fc11fb9a34dd140c7.tar.gz SMAPI-dbb9bd84306830456032778fc11fb9a34dd140c7.tar.bz2 SMAPI-dbb9bd84306830456032778fc11fb9a34dd140c7.zip |
Merge branch 'develop-1.9' into stable
Diffstat (limited to 'src/StardewModdingAPI/Framework/ModRegistry.cs')
-rw-r--r-- | src/StardewModdingAPI/Framework/ModRegistry.cs | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/StardewModdingAPI/Framework/ModRegistry.cs b/src/StardewModdingAPI/Framework/ModRegistry.cs index 209f1928..f015b7ba 100644 --- a/src/StardewModdingAPI/Framework/ModRegistry.cs +++ b/src/StardewModdingAPI/Framework/ModRegistry.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; +using StardewModdingAPI.Framework.Models; namespace StardewModdingAPI.Framework { @@ -18,10 +19,21 @@ namespace StardewModdingAPI.Framework /// <summary>The friendly mod names treated as deprecation warning sources (assembly full name => mod name).</summary> private readonly IDictionary<string, string> ModNamesByAssembly = new Dictionary<string, string>(); + /// <summary>Metadata about mods that SMAPI should assume is compatible or broken, regardless of whether it detects incompatible code.</summary> + private readonly ModCompatibility[] CompatibilityRecords; + /********* ** Public methods *********/ + /// <summary>Construct an instance.</summary> + /// <param name="compatibilityRecords">Metadata about mods that SMAPI should assume is compatible or broken, regardless of whether it detects incompatible code.</param> + public ModRegistry(IEnumerable<ModCompatibility> compatibilityRecords) + { + this.CompatibilityRecords = compatibilityRecords.ToArray(); + } + + /**** ** IModRegistry ****/ @@ -113,5 +125,21 @@ namespace StardewModdingAPI.Framework // no known assembly found return null; } + + /// <summary>Get metadata that indicates whether SMAPI should assume the mod is compatible or broken, regardless of whether it detects incompatible code.</summary> + /// <param name="manifest">The mod manifest.</param> + /// <returns>Returns the incompatibility record if applicable, else <c>null</c>.</returns> + internal ModCompatibility GetCompatibilityRecord(IManifest manifest) + { + string key = !string.IsNullOrWhiteSpace(manifest.UniqueID) ? manifest.UniqueID : manifest.EntryDll; + return ( + from mod in this.CompatibilityRecords + where + mod.ID == key + && (mod.LowerSemanticVersion == null || !manifest.Version.IsOlderThan(mod.LowerSemanticVersion)) + && !manifest.Version.IsNewerThan(mod.UpperSemanticVersion) + select mod + ).FirstOrDefault(); + } } -}
\ No newline at end of file +} |