summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/Serialisation
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2019-08-09 01:18:05 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2019-09-14 19:08:06 -0400
commitfd77ae93d59222d70c86aebfc044f3af11063372 (patch)
tree76fac6ffc0cac70fb44f8b9ffc72471a2796a02f /src/SMAPI/Framework/Serialisation
parent3f6865e8301535c8fbe83bc0f931a116adac0636 (diff)
downloadSMAPI-fd77ae93d59222d70c86aebfc044f3af11063372.tar.gz
SMAPI-fd77ae93d59222d70c86aebfc044f3af11063372.tar.bz2
SMAPI-fd77ae93d59222d70c86aebfc044f3af11063372.zip
fix typos and inconsistent spelling
Diffstat (limited to 'src/SMAPI/Framework/Serialisation')
-rw-r--r--src/SMAPI/Framework/Serialisation/ColorConverter.cs47
-rw-r--r--src/SMAPI/Framework/Serialisation/PointConverter.cs43
-rw-r--r--src/SMAPI/Framework/Serialisation/RectangleConverter.cs52
3 files changed, 0 insertions, 142 deletions
diff --git a/src/SMAPI/Framework/Serialisation/ColorConverter.cs b/src/SMAPI/Framework/Serialisation/ColorConverter.cs
deleted file mode 100644
index c27065bf..00000000
--- a/src/SMAPI/Framework/Serialisation/ColorConverter.cs
+++ /dev/null
@@ -1,47 +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="Color"/> for crossplatform compatibility.</summary>
- /// <remarks>
- /// - Linux/Mac format: { "B": 76, "G": 51, "R": 25, "A": 102 }
- /// - Windows format: "26, 51, 76, 102"
- /// </remarks>
- internal class ColorConverter : SimpleReadOnlyConverter<Color>
- {
- /*********
- ** 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 Color ReadObject(JObject obj, string path)
- {
- int r = obj.ValueIgnoreCase<int>(nameof(Color.R));
- int g = obj.ValueIgnoreCase<int>(nameof(Color.G));
- int b = obj.ValueIgnoreCase<int>(nameof(Color.B));
- int a = obj.ValueIgnoreCase<int>(nameof(Color.A));
- return new Color(r, g, b, a);
- }
-
- /// <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 Color ReadString(string str, string path)
- {
- string[] parts = str.Split(',');
- if (parts.Length != 4)
- throw new SParseException($"Can't parse {typeof(Color).Name} from invalid value '{str}' (path: {path}).");
-
- int r = Convert.ToInt32(parts[0]);
- int g = Convert.ToInt32(parts[1]);
- int b = Convert.ToInt32(parts[2]);
- int a = Convert.ToInt32(parts[3]);
- return new Color(r, g, b, a);
- }
- }
-}
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);
- }
- }
-}
diff --git a/src/SMAPI/Framework/Serialisation/RectangleConverter.cs b/src/SMAPI/Framework/Serialisation/RectangleConverter.cs
deleted file mode 100644
index 4f55cc32..00000000
--- a/src/SMAPI/Framework/Serialisation/RectangleConverter.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using System;
-using System.Text.RegularExpressions;
-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="Rectangle"/> for crossplatform compatibility.</summary>
- /// <remarks>
- /// - Linux/Mac format: { "X": 1, "Y": 2, "Width": 3, "Height": 4 }
- /// - Windows format: "{X:1 Y:2 Width:3 Height:4}"
- /// </remarks>
- internal class RectangleConverter : SimpleReadOnlyConverter<Rectangle>
- {
- /*********
- ** 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 Rectangle ReadObject(JObject obj, string path)
- {
- int x = obj.ValueIgnoreCase<int>(nameof(Rectangle.X));
- int y = obj.ValueIgnoreCase<int>(nameof(Rectangle.Y));
- int width = obj.ValueIgnoreCase<int>(nameof(Rectangle.Width));
- int height = obj.ValueIgnoreCase<int>(nameof(Rectangle.Height));
- return new Rectangle(x, y, width, height);
- }
-
- /// <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 Rectangle ReadString(string str, string path)
- {
- if (string.IsNullOrWhiteSpace(str))
- return Rectangle.Empty;
-
- var match = Regex.Match(str, @"^\{X:(?<x>\d+) Y:(?<y>\d+) Width:(?<width>\d+) Height:(?<height>\d+)\}$", RegexOptions.IgnoreCase);
- if (!match.Success)
- throw new SParseException($"Can't parse {typeof(Rectangle).Name} from invalid value '{str}' (path: {path}).");
-
- int x = Convert.ToInt32(match.Groups["x"].Value);
- int y = Convert.ToInt32(match.Groups["y"].Value);
- int width = Convert.ToInt32(match.Groups["width"].Value);
- int height = Convert.ToInt32(match.Groups["height"].Value);
-
- return new Rectangle(x, y, width, height);
- }
- }
-}