diff options
| author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2019-09-13 18:24:54 -0400 |
|---|---|---|
| committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2019-09-13 18:24:54 -0400 |
| commit | 6521df7b131924835eb797251c1e956fae0d6e13 (patch) | |
| tree | b704dc64b6b6fef72615bac8950d5eff3c80ea89 /src/StardewModdingAPI.Toolkit/Framework/ModData/ModDatabase.cs | |
| parent | e22a54212182d0adc443ac95bc791e83c90f7e10 (diff) | |
| parent | b7b8b001c5c2dc5d2c9fc1347532ca29368c2325 (diff) | |
| download | SMAPI-6521df7b131924835eb797251c1e956fae0d6e13.tar.gz SMAPI-6521df7b131924835eb797251c1e956fae0d6e13.tar.bz2 SMAPI-6521df7b131924835eb797251c1e956fae0d6e13.zip | |
Merge branch 'develop' into stable
Diffstat (limited to 'src/StardewModdingAPI.Toolkit/Framework/ModData/ModDatabase.cs')
| -rw-r--r-- | src/StardewModdingAPI.Toolkit/Framework/ModData/ModDatabase.cs | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/src/StardewModdingAPI.Toolkit/Framework/ModData/ModDatabase.cs b/src/StardewModdingAPI.Toolkit/Framework/ModData/ModDatabase.cs deleted file mode 100644 index a9da884a..00000000 --- a/src/StardewModdingAPI.Toolkit/Framework/ModData/ModDatabase.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace StardewModdingAPI.Toolkit.Framework.ModData -{ - /// <summary>Handles access to SMAPI's internal mod metadata list.</summary> - public class ModDatabase - { - /********* - ** Fields - *********/ - /// <summary>The underlying mod data records indexed by default display name.</summary> - private readonly ModDataRecord[] Records; - - /// <summary>Get an update URL for an update key (if valid).</summary> - private readonly Func<string, string> GetUpdateUrl; - - - /********* - ** Public methods - *********/ - /// <summary>Construct an empty instance.</summary> - public ModDatabase() - : this(new ModDataRecord[0], key => null) { } - - /// <summary>Construct an instance.</summary> - /// <param name="records">The underlying mod data records indexed by default display name.</param> - /// <param name="getUpdateUrl">Get an update URL for an update key (if valid).</param> - public ModDatabase(IEnumerable<ModDataRecord> records, Func<string, string> getUpdateUrl) - { - this.Records = records.ToArray(); - this.GetUpdateUrl = getUpdateUrl; - } - - /// <summary>Get all mod data records.</summary> - public IEnumerable<ModDataRecord> GetAll() - { - return this.Records; - } - - /// <summary>Get a mod data record.</summary> - /// <param name="modID">The unique mod ID.</param> - public ModDataRecord Get(string modID) - { - return !string.IsNullOrWhiteSpace(modID) - ? this.Records.FirstOrDefault(p => p.HasID(modID)) - : null; - } - - /// <summary>Get the mod page URL for a mod (if available).</summary> - /// <param name="id">The unique mod ID.</param> - public string GetModPageUrlFor(string id) - { - // get update key - ModDataRecord record = this.Get(id); - ModDataField updateKeyField = record?.Fields.FirstOrDefault(p => p.Key == ModDataFieldKey.UpdateKey); - if (updateKeyField == null) - return null; - - // get update URL - return this.GetUpdateUrl(updateKeyField.Value); - } - } -} |
