mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-05-29 10:24:34 +00:00
Core - Move PointJsonConverter class into PointJsonConverter.cs
This commit is contained in:
24
PckStudio.Core/IO/Java/PointJsonConverter.cs
Normal file
24
PckStudio.Core/IO/Java/PointJsonConverter.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace PckStudio.Core.IO.Java
|
||||
{
|
||||
public class PointJsonConverter : JsonConverter<Point>
|
||||
{
|
||||
public override void WriteJson(JsonWriter writer, Point value, JsonSerializer serializer)
|
||||
{
|
||||
JObject jo = new JObject();
|
||||
jo.Add("x", value.X);
|
||||
jo.Add("y", value.Y);
|
||||
jo.WriteTo(writer);
|
||||
}
|
||||
|
||||
public override Point ReadJson(JsonReader reader, Type objectType, Point existingValue, bool hasExistingValue, JsonSerializer serializer)
|
||||
{
|
||||
JObject jo = JObject.Load(reader);
|
||||
return new Point((int)(jo["x"] ?? 0), (int)(jo["y"] ?? 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,21 +21,4 @@ namespace PckStudio.Core.IO.Java
|
||||
return new Size((int)(jo["width"] ?? 0), (int)(jo["height"] ?? 0));
|
||||
}
|
||||
}
|
||||
|
||||
public class PointJsonConverter : JsonConverter<Point>
|
||||
{
|
||||
public override void WriteJson(JsonWriter writer, Point value, JsonSerializer serializer)
|
||||
{
|
||||
JObject jo = new JObject();
|
||||
jo.Add("x", value.X);
|
||||
jo.Add("y", value.Y);
|
||||
jo.WriteTo(writer);
|
||||
}
|
||||
|
||||
public override Point ReadJson(JsonReader reader, Type objectType, Point existingValue, bool hasExistingValue, JsonSerializer serializer)
|
||||
{
|
||||
JObject jo = JObject.Load(reader);
|
||||
return new Point((int)(jo["x"] ?? 0), (int)(jo["y"] ?? 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user