summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Framework/Serialisation
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-08-21 16:39:21 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-08-21 16:39:21 -0400
commit8ba54a682fd7de3756b6ddd262b232cf40d23ea0 (patch)
tree7e44d53b733d95b05b232da46306a0d3d57e9231 /src/StardewModdingAPI/Framework/Serialisation
parent674ad0d90f8780130a5fcefb3869acfe2315df2a (diff)
parenteea5100acea0bceaf440f9d1bd50ee2b24cf8ebc (diff)
downloadSMAPI-8ba54a682fd7de3756b6ddd262b232cf40d23ea0.tar.gz
SMAPI-8ba54a682fd7de3756b6ddd262b232cf40d23ea0.tar.bz2
SMAPI-8ba54a682fd7de3756b6ddd262b232cf40d23ea0.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/StardewModdingAPI/Framework/Serialisation')
-rw-r--r--src/StardewModdingAPI/Framework/Serialisation/SFieldConverter.cs (renamed from src/StardewModdingAPI/Framework/Serialisation/ManifestFieldConverter.cs)21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/StardewModdingAPI/Framework/Serialisation/ManifestFieldConverter.cs b/src/StardewModdingAPI/Framework/Serialisation/SFieldConverter.cs
index 6947311b..11ffdccb 100644
--- a/src/StardewModdingAPI/Framework/Serialisation/ManifestFieldConverter.cs
+++ b/src/StardewModdingAPI/Framework/Serialisation/SFieldConverter.cs
@@ -8,7 +8,7 @@ using StardewModdingAPI.Framework.Models;
namespace StardewModdingAPI.Framework.Serialisation
{
/// <summary>Overrides how SMAPI reads and writes <see cref="ISemanticVersion"/> and <see cref="IManifestDependency"/> fields.</summary>
- internal class ManifestFieldConverter : JsonConverter
+ internal class SFieldConverter : JsonConverter
{
/*********
** Accessors
@@ -24,7 +24,10 @@ namespace StardewModdingAPI.Framework.Serialisation
/// <param name="objectType">The object type.</param>
public override bool CanConvert(Type objectType)
{
- return objectType == typeof(ISemanticVersion) || objectType == typeof(IManifestDependency[]);
+ return
+ objectType == typeof(ISemanticVersion)
+ || objectType == typeof(IManifestDependency[])
+ || objectType == typeof(ModCompatibilityID[]);
}
/// <summary>Reads the JSON representation of the object.</summary>
@@ -83,6 +86,20 @@ namespace StardewModdingAPI.Framework.Serialisation
return result.ToArray();
}
+ // mod compatibility ID
+ if (objectType == typeof(ModCompatibilityID[]))
+ {
+ List<ModCompatibilityID> result = new List<ModCompatibilityID>();
+ foreach (JToken child in JArray.Load(reader).Children())
+ {
+ result.Add(child is JValue value
+ ? new ModCompatibilityID(value.Value<string>())
+ : child.ToObject<ModCompatibilityID>()
+ );
+ }
+ return result.ToArray();
+ }
+
// unknown
throw new NotSupportedException($"Unknown type '{objectType?.FullName}'.");
}