diff options
| author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2019-11-24 13:49:30 -0500 |
|---|---|---|
| committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2019-11-24 13:49:30 -0500 |
| commit | a3f21685049cabf2d824c8060dc0b1de47e9449e (patch) | |
| tree | ad9add30e9da2a50e0ea0245f1546b7378f0d282 /src/SMAPI/Framework/Serialisation/PointConverter.cs | |
| parent | 6521df7b131924835eb797251c1e956fae0d6e13 (diff) | |
| parent | 277bf082675b98b95bf6184fe3c7a45b969c7ac2 (diff) | |
| download | SMAPI-a3f21685049cabf2d824c8060dc0b1de47e9449e.tar.gz SMAPI-a3f21685049cabf2d824c8060dc0b1de47e9449e.tar.bz2 SMAPI-a3f21685049cabf2d824c8060dc0b1de47e9449e.zip | |
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI/Framework/Serialisation/PointConverter.cs')
| -rw-r--r-- | src/SMAPI/Framework/Serialisation/PointConverter.cs | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/src/SMAPI/Framework/Serialisation/PointConverter.cs b/src/SMAPI/Framework/Serialisation/PointConverter.cs deleted file mode 100644 index fbc857d2..00000000 --- a/src/SMAPI/Framework/Serialisation/PointConverter.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Newtonsoft.Json.Linq; -using StardewModdingAPI.Toolkit.Serialisation; -using StardewModdingAPI.Toolkit.Serialisation.Converters; - -namespace StardewModdingAPI.Framework.Serialisation -{ - /// <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); - } - } -} |
