From 9495cc0f493a11960aa23551e164018681d08f79 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 23 Sep 2017 22:07:29 -0400 Subject: rename mod compatibility records for broader use (#361) --- .../Framework/Models/ModCompatibilityID.cs | 57 ---------------------- 1 file changed, 57 deletions(-) delete mode 100644 src/StardewModdingAPI/Framework/Models/ModCompatibilityID.cs (limited to 'src/StardewModdingAPI/Framework/Models/ModCompatibilityID.cs') diff --git a/src/StardewModdingAPI/Framework/Models/ModCompatibilityID.cs b/src/StardewModdingAPI/Framework/Models/ModCompatibilityID.cs deleted file mode 100644 index 98e70116..00000000 --- a/src/StardewModdingAPI/Framework/Models/ModCompatibilityID.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using Newtonsoft.Json; - -namespace StardewModdingAPI.Framework.Models -{ - /// Uniquely identifies a mod for compatibility checks. - internal class ModCompatibilityID - { - /********* - ** Accessors - *********/ - /// The unique mod ID. - public string ID { get; set; } - - /// The mod name to disambiguate non-unique IDs, or null to ignore the mod name. - public string Name { get; set; } - - /// The author name to disambiguate non-unique IDs, or null to ignore the author. - public string Author { get; set; } - - - /********* - ** Public methods - *********/ - /// Construct an instance. - public ModCompatibilityID() { } - - /// Construct an instance. - /// The mod ID or a JSON string matching the fields. - public ModCompatibilityID(string data) - { - // JSON can be stuffed into the ID string as a convenience hack to keep JSON mod lists - // formatted readably. The tradeoff is that the format is a bit more magical, but that's - // probably acceptable since players aren't meant to edit it. It's also fairly clear what - // the JSON strings do, if not necessarily how. - if (data.StartsWith("{")) - JsonConvert.PopulateObject(data, this); - else - this.ID = data; - } - - /// Get whether this ID matches a given mod manifest. - /// The mod's unique ID, or a substitute ID if it isn't set in the manifest. - /// The manifest to check. - public bool Matches(string id, IManifest manifest) - { - return - this.ID.Equals(id, StringComparison.InvariantCultureIgnoreCase) - && ( - this.Author == null - || this.Author.Equals(manifest.Author, StringComparison.InvariantCultureIgnoreCase) - || (manifest.ExtraFields.ContainsKey("Authour") && this.Author.Equals(manifest.ExtraFields["Authour"].ToString(), StringComparison.InvariantCultureIgnoreCase)) - ) - && (this.Name == null || this.Name.Equals(manifest.Name, StringComparison.InvariantCultureIgnoreCase)); - } - } -} -- cgit