summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI.Toolkit/Framework/ModData/ParsedModDataRecord.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2018-06-27 00:05:53 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2018-06-27 00:05:53 -0400
commit5f19e4f2035c36f9c6c882da3767d6f29409db1c (patch)
treeb4b04714dd65ae3d6e487c346977dcba3536e0d6 /src/StardewModdingAPI.Toolkit/Framework/ModData/ParsedModDataRecord.cs
parent9f0cfee55632663473ee06c0586035cc47abe397 (diff)
downloadSMAPI-5f19e4f2035c36f9c6c882da3767d6f29409db1c.tar.gz
SMAPI-5f19e4f2035c36f9c6c882da3767d6f29409db1c.tar.bz2
SMAPI-5f19e4f2035c36f9c6c882da3767d6f29409db1c.zip
move mod DB parsing into toolkit (#532)
Diffstat (limited to 'src/StardewModdingAPI.Toolkit/Framework/ModData/ParsedModDataRecord.cs')
-rw-r--r--src/StardewModdingAPI.Toolkit/Framework/ModData/ParsedModDataRecord.cs51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/StardewModdingAPI.Toolkit/Framework/ModData/ParsedModDataRecord.cs b/src/StardewModdingAPI.Toolkit/Framework/ModData/ParsedModDataRecord.cs
new file mode 100644
index 00000000..74f11ea5
--- /dev/null
+++ b/src/StardewModdingAPI.Toolkit/Framework/ModData/ParsedModDataRecord.cs
@@ -0,0 +1,51 @@
+namespace StardewModdingAPI.Toolkit.Framework.ModData
+{
+ /// <summary>A parsed representation of the fields from a <see cref="ModDataRecord"/> for a specific manifest.</summary>
+ public class ParsedModDataRecord
+ {
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The underlying data record.</summary>
+ public ModDataRecord DataRecord { get; set; }
+
+ /// <summary>The default mod name to display when the name isn't available (e.g. during dependency checks).</summary>
+ public string DisplayName { get; set; }
+
+ /// <summary>The update key to apply.</summary>
+ public string UpdateKey { get; set; }
+
+ /// <summary>The alternative URL the player can check for an updated version.</summary>
+ public string AlternativeUrl { get; set; }
+
+ /// <summary>The predefined compatibility status.</summary>
+ public ModStatus Status { get; set; } = ModStatus.None;
+
+ /// <summary>A reason phrase for the <see cref="Status"/>, or <c>null</c> to use the default reason.</summary>
+ public string StatusReasonPhrase { get; set; }
+
+ /// <summary>The upper version for which the <see cref="Status"/> applies (if any).</summary>
+ public ISemanticVersion StatusUpperVersion { get; set; }
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Get a semantic local version for update checks.</summary>
+ /// <param name="version">The remote version to normalise.</param>
+ public ISemanticVersion GetLocalVersionForUpdateChecks(ISemanticVersion version)
+ {
+ return this.DataRecord.GetLocalVersionForUpdateChecks(version);
+ }
+
+ /// <summary>Get a semantic remote version for update checks.</summary>
+ /// <param name="version">The remote version to normalise.</param>
+ public ISemanticVersion GetRemoteVersionForUpdateChecks(string version)
+ {
+ string rawVersion = this.DataRecord.GetRemoteVersionForUpdateChecks(version);
+ return rawVersion != null
+ ? new SemanticVersion(rawVersion)
+ : null;
+ }
+ }
+}