summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Framework/Serialisation
diff options
context:
space:
mode:
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}'.");
}