diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-06-24 21:51:51 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-06-24 21:51:51 -0400 |
commit | b08e27d13a1f0c82656df95212fc40588b3b5314 (patch) | |
tree | ad38bb6d5bffc699ff0ba0ee0d5cd8e82f929a5f /src/SMAPI/Framework/Serialisation | |
parent | 316242eeb2b6b6e711ab98f64c147a59c1d0aab8 (diff) | |
download | SMAPI-b08e27d13a1f0c82656df95212fc40588b3b5314.tar.gz SMAPI-b08e27d13a1f0c82656df95212fc40588b3b5314.tar.bz2 SMAPI-b08e27d13a1f0c82656df95212fc40588b3b5314.zip |
merge IManifest interfaces into new project (#532)
Diffstat (limited to 'src/SMAPI/Framework/Serialisation')
-rw-r--r-- | src/SMAPI/Framework/Serialisation/SemanticVersionConverter.cs | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/src/SMAPI/Framework/Serialisation/SemanticVersionConverter.cs b/src/SMAPI/Framework/Serialisation/SemanticVersionConverter.cs deleted file mode 100644 index 3e05a440..00000000 --- a/src/SMAPI/Framework/Serialisation/SemanticVersionConverter.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Newtonsoft.Json.Linq; -using StardewModdingAPI.Toolkit.Serialisation; -using StardewModdingAPI.Toolkit.Serialisation.Converters; - -namespace StardewModdingAPI.Framework.Serialisation -{ - /// <summary>Handles deserialisation of <see cref="ISemanticVersion"/>.</summary> - internal class SemanticVersionConverter : SimpleReadOnlyConverter<ISemanticVersion> - { - /********* - ** Protected methods - *********/ - /// <summary>Read a JSON object.</summary> - /// <param name="obj">The JSON object to read.</param> - /// <param name="path">The path to the current JSON node.</param> - protected override ISemanticVersion ReadObject(JObject obj, string path) - { - int major = obj.ValueIgnoreCase<int>("MajorVersion"); - int minor = obj.ValueIgnoreCase<int>("MinorVersion"); - int patch = obj.ValueIgnoreCase<int>("PatchVersion"); - string build = obj.ValueIgnoreCase<string>("Build"); - if (build == "0") - build = null; // '0' from incorrect examples in old SMAPI documentation - - return new SemanticVersion(major, minor, patch, build); - } - - /// <summary>Read a JSON string.</summary> - /// <param name="str">The JSON string value.</param> - /// <param name="path">The path to the current JSON node.</param> - protected override ISemanticVersion ReadString(string str, string path) - { - if (string.IsNullOrWhiteSpace(str)) - return null; - if (!SemanticVersion.TryParse(str, out ISemanticVersion version)) - throw new SParseException($"Can't parse semantic version from invalid value '{str}', should be formatted like 1.2, 1.2.30, or 1.2.30-beta (path: {path})."); - return version; - } - } -} |