summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/Serialisation/CrossplatformConverters/PointConverter.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2018-06-05 20:22:46 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2018-06-05 20:22:46 -0400
commit625c538f244519700f3942b2b2969845db9a99b0 (patch)
treed13596220a62616838310cbcf0f0004e2f843da3 /src/SMAPI/Framework/Serialisation/CrossplatformConverters/PointConverter.cs
parent265ce35fd1db677230ddb16483b4d92e7c13a777 (diff)
downloadSMAPI-625c538f244519700f3942b2b2969845db9a99b0.tar.gz
SMAPI-625c538f244519700f3942b2b2969845db9a99b0.tar.bz2
SMAPI-625c538f244519700f3942b2b2969845db9a99b0.zip
move manifest parsing into toolkit (#532)
Diffstat (limited to 'src/SMAPI/Framework/Serialisation/CrossplatformConverters/PointConverter.cs')
-rw-r--r--src/SMAPI/Framework/Serialisation/CrossplatformConverters/PointConverter.cs42
1 files changed, 0 insertions, 42 deletions
diff --git a/src/SMAPI/Framework/Serialisation/CrossplatformConverters/PointConverter.cs b/src/SMAPI/Framework/Serialisation/CrossplatformConverters/PointConverter.cs
deleted file mode 100644
index 434b7ea5..00000000
--- a/src/SMAPI/Framework/Serialisation/CrossplatformConverters/PointConverter.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using System;
-using Microsoft.Xna.Framework;
-using Newtonsoft.Json.Linq;
-using StardewModdingAPI.Framework.Exceptions;
-
-namespace StardewModdingAPI.Framework.Serialisation.CrossplatformConverters
-{
- /// <summary>Handles deserialisation of <see cref="PointConverter"/> for crossplatform compatibility.</summary>
- /// <remarks>
- /// - Linux/Mac format: { "X": 1, "Y": 2 }
- /// - Windows format: "1, 2"
- /// </remarks>
- internal class PointConverter : SimpleReadOnlyConverter<Point>
- {
- /*********
- ** 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 Point ReadObject(JObject obj, string path)
- {
- int x = obj.ValueIgnoreCase<int>(nameof(Point.X));
- int y = obj.ValueIgnoreCase<int>(nameof(Point.Y));
- return new Point(x, y);
- }
-
- /// <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 Point ReadString(string str, string path)
- {
- string[] parts = str.Split(',');
- if (parts.Length != 2)
- throw new SParseException($"Can't parse {typeof(Point).Name} from invalid value '{str}' (path: {path}).");
-
- int x = Convert.ToInt32(parts[0]);
- int y = Convert.ToInt32(parts[1]);
- return new Point(x, y);
- }
- }
-}