Fixes formatting (#200)
This commit is contained in:
parent
1f651992d7
commit
86b7b3aed1
209 changed files with 51326 additions and 50397 deletions
|
|
@ -1,42 +1,42 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: IPEndPointConverter.cs *
|
||||
* Created: 2020/07/03 - Updated: 2020/07/03 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class IPEndPointConverter : JsonConverter<IPEndPoint>
|
||||
{
|
||||
public override IPEndPoint Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
if (IPEndPoint.TryParse(reader.GetString(), out var ipep))
|
||||
return ipep;
|
||||
|
||||
throw new JsonException("IPEndPoint must be in the correct format");
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, IPEndPoint value, JsonSerializerOptions options)
|
||||
=> writer.WriteStringValue(value.ToString());
|
||||
}
|
||||
}
|
||||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: IPEndPointConverter.cs *
|
||||
* Created: 2020/07/03 - Updated: 2020/07/03 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class IPEndPointConverter : JsonConverter<IPEndPoint>
|
||||
{
|
||||
public override IPEndPoint Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
if (IPEndPoint.TryParse(reader.GetString(), out var ipep))
|
||||
return ipep;
|
||||
|
||||
throw new JsonException("IPEndPoint must be in the correct format");
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, IPEndPoint value, JsonSerializerOptions options)
|
||||
=> writer.WriteStringValue(value.ToString());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,35 +1,36 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: IPEndPointConverterFactory.cs *
|
||||
* Created: 2020/07/03 - Updated: 2020/07/03 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class IPEndPointConverterFactory : JsonConverterFactory
|
||||
{
|
||||
public override bool CanConvert(Type typeToConvert) => typeToConvert == typeof(IPEndPoint);
|
||||
|
||||
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options) => new IPEndPointConverter();
|
||||
}
|
||||
}
|
||||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: IPEndPointConverterFactory.cs *
|
||||
* Created: 2020/07/03 - Updated: 2020/07/03 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class IPEndPointConverterFactory : JsonConverterFactory
|
||||
{
|
||||
public override bool CanConvert(Type typeToConvert) => typeToConvert == typeof(IPEndPoint);
|
||||
|
||||
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options) =>
|
||||
new IPEndPointConverter();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,35 +1,35 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: MapConverter.cs - Created: 2020/04/12 - Updated: 2020/05/02 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class MapConverter : JsonConverter<Map>
|
||||
{
|
||||
public override Map Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
=> Map.Parse(reader.GetString());
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, Map value, JsonSerializerOptions options)
|
||||
=> writer.WriteStringValue(value.Name);
|
||||
}
|
||||
}
|
||||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: MapConverter.cs - Created: 2020/04/12 - Updated: 2020/05/02 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class MapConverter : JsonConverter<Map>
|
||||
{
|
||||
public override Map Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
=> Map.Parse(reader.GetString());
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, Map value, JsonSerializerOptions options)
|
||||
=> writer.WriteStringValue(value.Name);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,34 +1,35 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: MapConverterFactory.cs *
|
||||
* Created: 2020/05/23 - Updated: 2020/05/23 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class MapConverterFactory : JsonConverterFactory
|
||||
{
|
||||
public override bool CanConvert(Type typeToConvert) => typeToConvert == typeof(Map);
|
||||
|
||||
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options) => new MapConverter();
|
||||
}
|
||||
}
|
||||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: MapConverterFactory.cs *
|
||||
* Created: 2020/05/23 - Updated: 2020/05/23 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class MapConverterFactory : JsonConverterFactory
|
||||
{
|
||||
public override bool CanConvert(Type typeToConvert) => typeToConvert == typeof(Map);
|
||||
|
||||
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options) =>
|
||||
new MapConverter();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,105 +1,105 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: Point2DConverter.cs *
|
||||
* Created: 2020/04/12 - Updated: 2020/05/23 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class Point2DConverter : JsonConverter<Point2D>
|
||||
{
|
||||
private Point2D DeserializeArray(ref Utf8JsonReader reader)
|
||||
{
|
||||
Span<int> data = stackalloc int[2];
|
||||
var count = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
reader.Read();
|
||||
if (reader.TokenType == JsonTokenType.EndArray)
|
||||
break;
|
||||
|
||||
if (reader.TokenType == JsonTokenType.Number)
|
||||
{
|
||||
if (count < 2)
|
||||
data[count] = reader.GetInt32();
|
||||
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (count > 2)
|
||||
throw new JsonException("Point2D must be an array of x, y");
|
||||
|
||||
return new Point2D(data[0], data[1]);
|
||||
}
|
||||
|
||||
private Point2D DeserializeObj(ref Utf8JsonReader reader)
|
||||
{
|
||||
Span<int> data = stackalloc int[2];
|
||||
|
||||
while (true)
|
||||
{
|
||||
reader.Read();
|
||||
if (reader.TokenType == JsonTokenType.EndObject)
|
||||
break;
|
||||
|
||||
if (reader.TokenType != JsonTokenType.PropertyName)
|
||||
throw new JsonException("Invalid json structure for Point2D object");
|
||||
|
||||
var key = reader.GetString();
|
||||
|
||||
var i = key switch
|
||||
{
|
||||
"x" => 0,
|
||||
"y" => 1,
|
||||
_ => throw new JsonException($"Invalid property {key} for Point2D")
|
||||
};
|
||||
|
||||
reader.Read();
|
||||
|
||||
if (reader.TokenType != JsonTokenType.Number)
|
||||
throw new JsonException($"Value for {key} must be a number");
|
||||
|
||||
data[i] = reader.GetInt32();
|
||||
}
|
||||
|
||||
return new Point2D(data[0], data[1]);
|
||||
}
|
||||
|
||||
public override Point2D Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) =>
|
||||
reader.TokenType switch
|
||||
{
|
||||
JsonTokenType.StartArray => DeserializeArray(ref reader),
|
||||
JsonTokenType.StartObject => DeserializeObj(ref reader),
|
||||
_ => throw new JsonException("Invalid Json for Point3D")
|
||||
};
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, Point2D value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStartArray();
|
||||
writer.WriteNumberValue(value.X);
|
||||
writer.WriteNumberValue(value.Y);
|
||||
writer.WriteEndArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: Point2DConverter.cs *
|
||||
* Created: 2020/04/12 - Updated: 2020/05/23 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class Point2DConverter : JsonConverter<Point2D>
|
||||
{
|
||||
private Point2D DeserializeArray(ref Utf8JsonReader reader)
|
||||
{
|
||||
Span<int> data = stackalloc int[2];
|
||||
var count = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
reader.Read();
|
||||
if (reader.TokenType == JsonTokenType.EndArray)
|
||||
break;
|
||||
|
||||
if (reader.TokenType == JsonTokenType.Number)
|
||||
{
|
||||
if (count < 2)
|
||||
data[count] = reader.GetInt32();
|
||||
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (count > 2)
|
||||
throw new JsonException("Point2D must be an array of x, y");
|
||||
|
||||
return new Point2D(data[0], data[1]);
|
||||
}
|
||||
|
||||
private Point2D DeserializeObj(ref Utf8JsonReader reader)
|
||||
{
|
||||
Span<int> data = stackalloc int[2];
|
||||
|
||||
while (true)
|
||||
{
|
||||
reader.Read();
|
||||
if (reader.TokenType == JsonTokenType.EndObject)
|
||||
break;
|
||||
|
||||
if (reader.TokenType != JsonTokenType.PropertyName)
|
||||
throw new JsonException("Invalid json structure for Point2D object");
|
||||
|
||||
var key = reader.GetString();
|
||||
|
||||
var i = key switch
|
||||
{
|
||||
"x" => 0,
|
||||
"y" => 1,
|
||||
_ => throw new JsonException($"Invalid property {key} for Point2D")
|
||||
};
|
||||
|
||||
reader.Read();
|
||||
|
||||
if (reader.TokenType != JsonTokenType.Number)
|
||||
throw new JsonException($"Value for {key} must be a number");
|
||||
|
||||
data[i] = reader.GetInt32();
|
||||
}
|
||||
|
||||
return new Point2D(data[0], data[1]);
|
||||
}
|
||||
|
||||
public override Point2D Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) =>
|
||||
reader.TokenType switch
|
||||
{
|
||||
JsonTokenType.StartArray => DeserializeArray(ref reader),
|
||||
JsonTokenType.StartObject => DeserializeObj(ref reader),
|
||||
_ => throw new JsonException("Invalid Json for Point3D")
|
||||
};
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, Point2D value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStartArray();
|
||||
writer.WriteNumberValue(value.X);
|
||||
writer.WriteNumberValue(value.Y);
|
||||
writer.WriteEndArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,34 +1,36 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: Point2DConverterFactory.cs *
|
||||
* Created: 2020/05/23 - Updated: 2020/05/23 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class Point2DConverterFactory : JsonConverterFactory
|
||||
{
|
||||
public override bool CanConvert(Type typeToConvert) => typeToConvert == typeof(Point2D) || typeToConvert == typeof(IPoint2D);
|
||||
|
||||
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options) => new Point2DConverter();
|
||||
}
|
||||
}
|
||||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: Point2DConverterFactory.cs *
|
||||
* Created: 2020/05/23 - Updated: 2020/05/23 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class Point2DConverterFactory : JsonConverterFactory
|
||||
{
|
||||
public override bool CanConvert(Type typeToConvert) =>
|
||||
typeToConvert == typeof(Point2D) || typeToConvert == typeof(IPoint2D);
|
||||
|
||||
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options) =>
|
||||
new Point2DConverter();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,107 +1,107 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: Point3DConverter.cs *
|
||||
* Created: 2020/04/12 - Updated: 2020/05/23 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class Point3DConverter : JsonConverter<Point3D>
|
||||
{
|
||||
private Point3D DeserializeArray(ref Utf8JsonReader reader)
|
||||
{
|
||||
Span<int> data = stackalloc int[3];
|
||||
var count = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
reader.Read();
|
||||
if (reader.TokenType == JsonTokenType.EndArray)
|
||||
break;
|
||||
|
||||
if (reader.TokenType == JsonTokenType.Number)
|
||||
{
|
||||
if (count < 3)
|
||||
data[count] = reader.GetInt32();
|
||||
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (count > 3)
|
||||
throw new JsonException("Point3D must be an array of x, y, z");
|
||||
|
||||
return new Point3D(data[0], data[1], data[2]);
|
||||
}
|
||||
|
||||
private Point3D DeserializeObj(ref Utf8JsonReader reader)
|
||||
{
|
||||
Span<int> data = stackalloc int[3];
|
||||
|
||||
while (true)
|
||||
{
|
||||
reader.Read();
|
||||
if (reader.TokenType == JsonTokenType.EndObject)
|
||||
break;
|
||||
|
||||
if (reader.TokenType != JsonTokenType.PropertyName)
|
||||
throw new JsonException("Invalid json structure for Point3D object");
|
||||
|
||||
var key = reader.GetString();
|
||||
|
||||
var i = key switch
|
||||
{
|
||||
"x" => 0,
|
||||
"y" => 1,
|
||||
"z" => 2,
|
||||
_ => throw new JsonException($"Invalid property {key} for Point3D")
|
||||
};
|
||||
|
||||
reader.Read();
|
||||
|
||||
if (reader.TokenType != JsonTokenType.Number)
|
||||
throw new JsonException($"Value for {key} must be a number");
|
||||
|
||||
data[i] = reader.GetInt32();
|
||||
}
|
||||
|
||||
return new Point3D(data[0], data[1], data[2]);
|
||||
}
|
||||
|
||||
public override Point3D Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) =>
|
||||
reader.TokenType switch
|
||||
{
|
||||
JsonTokenType.StartArray => DeserializeArray(ref reader),
|
||||
JsonTokenType.StartObject => DeserializeObj(ref reader),
|
||||
_ => throw new JsonException("Invalid Json for Point3D")
|
||||
};
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, Point3D value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStartArray();
|
||||
writer.WriteNumberValue(value.X);
|
||||
writer.WriteNumberValue(value.Y);
|
||||
writer.WriteNumberValue(value.Z);
|
||||
writer.WriteEndArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: Point3DConverter.cs *
|
||||
* Created: 2020/04/12 - Updated: 2020/05/23 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class Point3DConverter : JsonConverter<Point3D>
|
||||
{
|
||||
private Point3D DeserializeArray(ref Utf8JsonReader reader)
|
||||
{
|
||||
Span<int> data = stackalloc int[3];
|
||||
var count = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
reader.Read();
|
||||
if (reader.TokenType == JsonTokenType.EndArray)
|
||||
break;
|
||||
|
||||
if (reader.TokenType == JsonTokenType.Number)
|
||||
{
|
||||
if (count < 3)
|
||||
data[count] = reader.GetInt32();
|
||||
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (count > 3)
|
||||
throw new JsonException("Point3D must be an array of x, y, z");
|
||||
|
||||
return new Point3D(data[0], data[1], data[2]);
|
||||
}
|
||||
|
||||
private Point3D DeserializeObj(ref Utf8JsonReader reader)
|
||||
{
|
||||
Span<int> data = stackalloc int[3];
|
||||
|
||||
while (true)
|
||||
{
|
||||
reader.Read();
|
||||
if (reader.TokenType == JsonTokenType.EndObject)
|
||||
break;
|
||||
|
||||
if (reader.TokenType != JsonTokenType.PropertyName)
|
||||
throw new JsonException("Invalid json structure for Point3D object");
|
||||
|
||||
var key = reader.GetString();
|
||||
|
||||
var i = key switch
|
||||
{
|
||||
"x" => 0,
|
||||
"y" => 1,
|
||||
"z" => 2,
|
||||
_ => throw new JsonException($"Invalid property {key} for Point3D")
|
||||
};
|
||||
|
||||
reader.Read();
|
||||
|
||||
if (reader.TokenType != JsonTokenType.Number)
|
||||
throw new JsonException($"Value for {key} must be a number");
|
||||
|
||||
data[i] = reader.GetInt32();
|
||||
}
|
||||
|
||||
return new Point3D(data[0], data[1], data[2]);
|
||||
}
|
||||
|
||||
public override Point3D Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) =>
|
||||
reader.TokenType switch
|
||||
{
|
||||
JsonTokenType.StartArray => DeserializeArray(ref reader),
|
||||
JsonTokenType.StartObject => DeserializeObj(ref reader),
|
||||
_ => throw new JsonException("Invalid Json for Point3D")
|
||||
};
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, Point3D value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStartArray();
|
||||
writer.WriteNumberValue(value.X);
|
||||
writer.WriteNumberValue(value.Y);
|
||||
writer.WriteNumberValue(value.Z);
|
||||
writer.WriteEndArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,34 +1,36 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: Point3DConverterFactory.cs *
|
||||
* Created: 2020/05/23 - Updated: 2020/05/23 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class Point3DConverterFactory : JsonConverterFactory
|
||||
{
|
||||
public override bool CanConvert(Type typeToConvert) => typeToConvert == typeof(Point3D) || typeToConvert == typeof(IPoint3D);
|
||||
|
||||
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options) => new Point3DConverter();
|
||||
}
|
||||
}
|
||||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: Point3DConverterFactory.cs *
|
||||
* Created: 2020/05/23 - Updated: 2020/05/23 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class Point3DConverterFactory : JsonConverterFactory
|
||||
{
|
||||
public override bool CanConvert(Type typeToConvert) =>
|
||||
typeToConvert == typeof(Point3D) || typeToConvert == typeof(IPoint3D);
|
||||
|
||||
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options) =>
|
||||
new Point3DConverter();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,156 +1,156 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: Rectangle3DConverter.cs *
|
||||
* Created: 2020/05/23 - Updated: 2020/05/23 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class Rectangle3DConverter : JsonConverter<Rectangle3D>
|
||||
{
|
||||
private Rectangle3D DeserializeArray(ref Utf8JsonReader reader)
|
||||
{
|
||||
Span<int> data = stackalloc int[6];
|
||||
var count = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
reader.Read();
|
||||
if (reader.TokenType == JsonTokenType.EndArray)
|
||||
break;
|
||||
|
||||
if (reader.TokenType == JsonTokenType.Number)
|
||||
{
|
||||
if (count < 6)
|
||||
data[count] = reader.GetInt32();
|
||||
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (count > 6)
|
||||
throw new JsonException("Rectangle3D must be an array of x, y, z, h, w, d");
|
||||
|
||||
return new Rectangle3D(data[0], data[1], data[2], data[3], data[4], data[5]);
|
||||
}
|
||||
|
||||
private Rectangle3D DeserializeObj(ref Utf8JsonReader reader, JsonSerializerOptions options)
|
||||
{
|
||||
Span<int> data = stackalloc int[6];
|
||||
|
||||
// 0 - xyzwhd, 1 - x1y1z1x2y2z2, 2 - start/end
|
||||
int objType = -1;
|
||||
|
||||
while (true)
|
||||
{
|
||||
reader.Read();
|
||||
if (reader.TokenType == JsonTokenType.EndObject)
|
||||
break;
|
||||
|
||||
if (reader.TokenType != JsonTokenType.PropertyName)
|
||||
throw new JsonException("Invalid json structure for Rectangle3D object");
|
||||
|
||||
var key = reader.GetString();
|
||||
|
||||
reader.Read();
|
||||
|
||||
if (key == "start" || key == "end")
|
||||
{
|
||||
if (objType > -1 && objType != 2)
|
||||
throw new JsonException("Rectangle3D must have a start/end, or x/y/z/w/h/d, but not both.");
|
||||
|
||||
objType = 2;
|
||||
|
||||
var point3D = reader.ToObject<Point3D>(options);
|
||||
var offset = key == "end" ? 3 : 0;
|
||||
data[0 + offset] = point3D.X;
|
||||
data[1 + offset] = point3D.Y;
|
||||
data[1 + offset] = point3D.Z;
|
||||
continue;
|
||||
}
|
||||
|
||||
var i = key switch
|
||||
{
|
||||
"x" => 0,
|
||||
"y" => 1,
|
||||
"z" => 2,
|
||||
"w" => 3,
|
||||
"width" => 3,
|
||||
"h" => 4,
|
||||
"height" => 4,
|
||||
"d" => 5,
|
||||
"depth" => 5,
|
||||
"x1" => 10,
|
||||
"y1" => 11,
|
||||
"z1" => 12,
|
||||
"x2" => 13,
|
||||
"y2" => 14,
|
||||
"z2" => 15,
|
||||
_ => throw new JsonException($"Invalid property {key} for Rectangle3D")
|
||||
};
|
||||
|
||||
if (i < 10)
|
||||
{
|
||||
if (objType > -1 && objType != 0)
|
||||
throw new JsonException("Rectangle3D must have a start/end, or x/y/z/w/h/d, but not both.");
|
||||
|
||||
objType = 0;
|
||||
data[i] = reader.GetInt32();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (objType > -1 && objType != 1)
|
||||
throw new JsonException("Rectangle3D must have a start/end, or x/y/z/w/h/d, but not both.");
|
||||
|
||||
objType = 1;
|
||||
data[i - 10] = reader.GetInt32();
|
||||
}
|
||||
|
||||
return objType == 0
|
||||
? new Rectangle3D(data[0], data[1], data[2], data[3], data[4], data[5])
|
||||
: new Rectangle3D(
|
||||
new Point3D(data[0], data[1], data[2]),
|
||||
new Point3D(data[3], data[4], data[5])
|
||||
);
|
||||
}
|
||||
|
||||
public override Rectangle3D Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) =>
|
||||
reader.TokenType switch
|
||||
{
|
||||
JsonTokenType.StartArray => DeserializeArray(ref reader),
|
||||
JsonTokenType.StartObject => DeserializeObj(ref reader, options),
|
||||
_ => throw new JsonException("Invalid Json for Point3D")
|
||||
};
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, Rectangle3D value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStartArray();
|
||||
writer.WriteNumberValue(value.Start.X);
|
||||
writer.WriteNumberValue(value.Start.Y);
|
||||
writer.WriteNumberValue(value.Start.Z);
|
||||
writer.WriteNumberValue(value.Width);
|
||||
writer.WriteNumberValue(value.Height);
|
||||
writer.WriteNumberValue(value.Depth);
|
||||
writer.WriteEndArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: Rectangle3DConverter.cs *
|
||||
* Created: 2020/05/23 - Updated: 2020/05/23 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class Rectangle3DConverter : JsonConverter<Rectangle3D>
|
||||
{
|
||||
private Rectangle3D DeserializeArray(ref Utf8JsonReader reader)
|
||||
{
|
||||
Span<int> data = stackalloc int[6];
|
||||
var count = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
reader.Read();
|
||||
if (reader.TokenType == JsonTokenType.EndArray)
|
||||
break;
|
||||
|
||||
if (reader.TokenType == JsonTokenType.Number)
|
||||
{
|
||||
if (count < 6)
|
||||
data[count] = reader.GetInt32();
|
||||
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (count > 6)
|
||||
throw new JsonException("Rectangle3D must be an array of x, y, z, h, w, d");
|
||||
|
||||
return new Rectangle3D(data[0], data[1], data[2], data[3], data[4], data[5]);
|
||||
}
|
||||
|
||||
private Rectangle3D DeserializeObj(ref Utf8JsonReader reader, JsonSerializerOptions options)
|
||||
{
|
||||
Span<int> data = stackalloc int[6];
|
||||
|
||||
// 0 - xyzwhd, 1 - x1y1z1x2y2z2, 2 - start/end
|
||||
var objType = -1;
|
||||
|
||||
while (true)
|
||||
{
|
||||
reader.Read();
|
||||
if (reader.TokenType == JsonTokenType.EndObject)
|
||||
break;
|
||||
|
||||
if (reader.TokenType != JsonTokenType.PropertyName)
|
||||
throw new JsonException("Invalid json structure for Rectangle3D object");
|
||||
|
||||
var key = reader.GetString();
|
||||
|
||||
reader.Read();
|
||||
|
||||
if (key == "start" || key == "end")
|
||||
{
|
||||
if (objType > -1 && objType != 2)
|
||||
throw new JsonException("Rectangle3D must have a start/end, or x/y/z/w/h/d, but not both.");
|
||||
|
||||
objType = 2;
|
||||
|
||||
var point3D = reader.ToObject<Point3D>(options);
|
||||
var offset = key == "end" ? 3 : 0;
|
||||
data[0 + offset] = point3D.X;
|
||||
data[1 + offset] = point3D.Y;
|
||||
data[1 + offset] = point3D.Z;
|
||||
continue;
|
||||
}
|
||||
|
||||
var i = key switch
|
||||
{
|
||||
"x" => 0,
|
||||
"y" => 1,
|
||||
"z" => 2,
|
||||
"w" => 3,
|
||||
"width" => 3,
|
||||
"h" => 4,
|
||||
"height" => 4,
|
||||
"d" => 5,
|
||||
"depth" => 5,
|
||||
"x1" => 10,
|
||||
"y1" => 11,
|
||||
"z1" => 12,
|
||||
"x2" => 13,
|
||||
"y2" => 14,
|
||||
"z2" => 15,
|
||||
_ => throw new JsonException($"Invalid property {key} for Rectangle3D")
|
||||
};
|
||||
|
||||
if (i < 10)
|
||||
{
|
||||
if (objType > -1 && objType != 0)
|
||||
throw new JsonException("Rectangle3D must have a start/end, or x/y/z/w/h/d, but not both.");
|
||||
|
||||
objType = 0;
|
||||
data[i] = reader.GetInt32();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (objType > -1 && objType != 1)
|
||||
throw new JsonException("Rectangle3D must have a start/end, or x/y/z/w/h/d, but not both.");
|
||||
|
||||
objType = 1;
|
||||
data[i - 10] = reader.GetInt32();
|
||||
}
|
||||
|
||||
return objType == 0
|
||||
? new Rectangle3D(data[0], data[1], data[2], data[3], data[4], data[5])
|
||||
: new Rectangle3D(
|
||||
new Point3D(data[0], data[1], data[2]),
|
||||
new Point3D(data[3], data[4], data[5])
|
||||
);
|
||||
}
|
||||
|
||||
public override Rectangle3D Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) =>
|
||||
reader.TokenType switch
|
||||
{
|
||||
JsonTokenType.StartArray => DeserializeArray(ref reader),
|
||||
JsonTokenType.StartObject => DeserializeObj(ref reader, options),
|
||||
_ => throw new JsonException("Invalid Json for Point3D")
|
||||
};
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, Rectangle3D value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStartArray();
|
||||
writer.WriteNumberValue(value.Start.X);
|
||||
writer.WriteNumberValue(value.Start.Y);
|
||||
writer.WriteNumberValue(value.Start.Z);
|
||||
writer.WriteNumberValue(value.Width);
|
||||
writer.WriteNumberValue(value.Height);
|
||||
writer.WriteNumberValue(value.Depth);
|
||||
writer.WriteEndArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,35 +1,35 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: Rectangle3DConverterFactory.cs *
|
||||
* Created: 2020/05/23 - Updated: 2020/05/23 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class Rectangle3DConverterFactory : JsonConverterFactory
|
||||
{
|
||||
public override bool CanConvert(Type typeToConvert) => typeToConvert == typeof(Rectangle3D);
|
||||
|
||||
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options) =>
|
||||
new Rectangle3DConverter();
|
||||
}
|
||||
}
|
||||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: Rectangle3DConverterFactory.cs *
|
||||
* Created: 2020/05/23 - Updated: 2020/05/23 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class Rectangle3DConverterFactory : JsonConverterFactory
|
||||
{
|
||||
public override bool CanConvert(Type typeToConvert) => typeToConvert == typeof(Rectangle3D);
|
||||
|
||||
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options) =>
|
||||
new Rectangle3DConverter();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,36 +1,36 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: TimeSpanConverter.cs *
|
||||
* Created: 2020/04/12 - Updated: 2020/05/02 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class TimeSpanConverter : JsonConverter<TimeSpan>
|
||||
{
|
||||
public override TimeSpan Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
=> TimeSpan.Parse(reader.GetString());
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, TimeSpan value, JsonSerializerOptions options)
|
||||
=> writer.WriteStringValue(value.ToString());
|
||||
}
|
||||
}
|
||||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: TimeSpanConverter.cs *
|
||||
* Created: 2020/04/12 - Updated: 2020/05/02 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class TimeSpanConverter : JsonConverter<TimeSpan>
|
||||
{
|
||||
public override TimeSpan Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
=> TimeSpan.Parse(reader.GetString());
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, TimeSpan value, JsonSerializerOptions options)
|
||||
=> writer.WriteStringValue(value.ToString());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,34 +1,35 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: TimeSpanConverterFactory.cs *
|
||||
* Created: 2020/05/23 - Updated: 2020/05/23 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class TimeSpanConverterFactory : JsonConverterFactory
|
||||
{
|
||||
public override bool CanConvert(Type typeToConvert) => typeToConvert == typeof(TimeSpan);
|
||||
|
||||
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options) => new TimeSpanConverter();
|
||||
}
|
||||
}
|
||||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: TimeSpanConverterFactory.cs *
|
||||
* Created: 2020/05/23 - Updated: 2020/05/23 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class TimeSpanConverterFactory : JsonConverterFactory
|
||||
{
|
||||
public override bool CanConvert(Type typeToConvert) => typeToConvert == typeof(TimeSpan);
|
||||
|
||||
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options) =>
|
||||
new TimeSpanConverter();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,160 +1,160 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: WorldLocationConverter.cs *
|
||||
* Created: 2020/05/31 - Updated: 2020/05/31 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class WorldLocationConverter : JsonConverter<WorldLocation>
|
||||
{
|
||||
private WorldLocation DeserializeArray(ref Utf8JsonReader reader)
|
||||
{
|
||||
Span<int> data = stackalloc int[3];
|
||||
var count = 0;
|
||||
bool hasMap = false;
|
||||
Map map = null;
|
||||
|
||||
while (true)
|
||||
{
|
||||
reader.Read();
|
||||
if (reader.TokenType == JsonTokenType.EndArray)
|
||||
break;
|
||||
|
||||
if (reader.TokenType == JsonTokenType.Number)
|
||||
{
|
||||
if (count < 3)
|
||||
data[count] = reader.GetInt32();
|
||||
else if (count == 3)
|
||||
map = Map.Maps[reader.GetInt32()];
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
if (reader.TokenType == JsonTokenType.String)
|
||||
{
|
||||
map = Map.Parse(reader.GetString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasMap || count < 3 || count > 4)
|
||||
throw new JsonException("WorldLocation must be an array of x, y, z, and map");
|
||||
|
||||
return new WorldLocation(data[0], data[1], data[2], map);
|
||||
}
|
||||
|
||||
private WorldLocation DeserializeObj(ref Utf8JsonReader reader, JsonSerializerOptions options)
|
||||
{
|
||||
Span<int> data = stackalloc int[3];
|
||||
int count = 0;
|
||||
bool hasLoc = false;
|
||||
bool hasXYZ = false;
|
||||
bool hasMap = false;
|
||||
Map map = null;
|
||||
|
||||
while (true)
|
||||
{
|
||||
reader.Read();
|
||||
if (reader.TokenType == JsonTokenType.EndObject)
|
||||
break;
|
||||
|
||||
if (reader.TokenType != JsonTokenType.PropertyName)
|
||||
throw new JsonException("Invalid Json structure for WorldLocation object");
|
||||
|
||||
var key = reader.GetString();
|
||||
|
||||
var i = key switch
|
||||
{
|
||||
"x" => 0,
|
||||
"y" => 1,
|
||||
"z" => 2,
|
||||
"loc" => 3,
|
||||
"map" => 4,
|
||||
_ => 5
|
||||
};
|
||||
|
||||
if (i == 5)
|
||||
continue;
|
||||
|
||||
reader.Read();
|
||||
|
||||
if (i < 3)
|
||||
{
|
||||
if (hasLoc)
|
||||
throw new JsonException("WorldLocation must have loc or x, y, z, but not both");
|
||||
|
||||
if (reader.TokenType != JsonTokenType.Number)
|
||||
throw new JsonException($"Value for {key} must be a number");
|
||||
|
||||
hasXYZ = true;
|
||||
data[i] = reader.GetInt32();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i == 3)
|
||||
{
|
||||
if (hasXYZ)
|
||||
throw new JsonException("WorldLocation must have loc or x, y, z, but not both");
|
||||
|
||||
hasLoc = true;
|
||||
Point3D loc = new Point3DConverter().Read(ref reader, typeof(Point3D), options);
|
||||
data[0] = loc.X;
|
||||
data[1] = loc.Y;
|
||||
data[2] = loc.Z;
|
||||
count = 3;
|
||||
continue;
|
||||
}
|
||||
|
||||
map = reader.TokenType switch
|
||||
{
|
||||
JsonTokenType.String => Map.Parse(reader.GetString()),
|
||||
JsonTokenType.Number => Map.Maps[reader.GetInt32()],
|
||||
_ => throw new JsonException($"Value for {key} must be a number or string")
|
||||
};
|
||||
}
|
||||
|
||||
if (!hasMap || count < 2)
|
||||
throw new JsonException("WorldLocation must have an x, y, z, and map properties");
|
||||
|
||||
return new WorldLocation(data[0], data[1], data[2], map);
|
||||
}
|
||||
|
||||
public override WorldLocation Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) =>
|
||||
reader.TokenType switch
|
||||
{
|
||||
JsonTokenType.StartArray => DeserializeArray(ref reader),
|
||||
JsonTokenType.StartObject => DeserializeObj(ref reader, options),
|
||||
_ => throw new JsonException("Invalid Json for Point3D")
|
||||
};
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, WorldLocation value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStartArray();
|
||||
writer.WriteNumberValue(value.X);
|
||||
writer.WriteNumberValue(value.Y);
|
||||
writer.WriteNumberValue(value.Z);
|
||||
writer.WriteStringValue(value.Map.ToString());
|
||||
writer.WriteEndArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: WorldLocationConverter.cs *
|
||||
* Created: 2020/05/31 - Updated: 2020/05/31 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class WorldLocationConverter : JsonConverter<WorldLocation>
|
||||
{
|
||||
private WorldLocation DeserializeArray(ref Utf8JsonReader reader)
|
||||
{
|
||||
Span<int> data = stackalloc int[3];
|
||||
var count = 0;
|
||||
var hasMap = false;
|
||||
Map map = null;
|
||||
|
||||
while (true)
|
||||
{
|
||||
reader.Read();
|
||||
if (reader.TokenType == JsonTokenType.EndArray)
|
||||
break;
|
||||
|
||||
if (reader.TokenType == JsonTokenType.Number)
|
||||
{
|
||||
if (count < 3)
|
||||
data[count] = reader.GetInt32();
|
||||
else if (count == 3)
|
||||
map = Map.Maps[reader.GetInt32()];
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
if (reader.TokenType == JsonTokenType.String)
|
||||
{
|
||||
map = Map.Parse(reader.GetString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasMap || count < 3 || count > 4)
|
||||
throw new JsonException("WorldLocation must be an array of x, y, z, and map");
|
||||
|
||||
return new WorldLocation(data[0], data[1], data[2], map);
|
||||
}
|
||||
|
||||
private WorldLocation DeserializeObj(ref Utf8JsonReader reader, JsonSerializerOptions options)
|
||||
{
|
||||
Span<int> data = stackalloc int[3];
|
||||
var count = 0;
|
||||
var hasLoc = false;
|
||||
var hasXYZ = false;
|
||||
var hasMap = false;
|
||||
Map map = null;
|
||||
|
||||
while (true)
|
||||
{
|
||||
reader.Read();
|
||||
if (reader.TokenType == JsonTokenType.EndObject)
|
||||
break;
|
||||
|
||||
if (reader.TokenType != JsonTokenType.PropertyName)
|
||||
throw new JsonException("Invalid Json structure for WorldLocation object");
|
||||
|
||||
var key = reader.GetString();
|
||||
|
||||
var i = key switch
|
||||
{
|
||||
"x" => 0,
|
||||
"y" => 1,
|
||||
"z" => 2,
|
||||
"loc" => 3,
|
||||
"map" => 4,
|
||||
_ => 5
|
||||
};
|
||||
|
||||
if (i == 5)
|
||||
continue;
|
||||
|
||||
reader.Read();
|
||||
|
||||
if (i < 3)
|
||||
{
|
||||
if (hasLoc)
|
||||
throw new JsonException("WorldLocation must have loc or x, y, z, but not both");
|
||||
|
||||
if (reader.TokenType != JsonTokenType.Number)
|
||||
throw new JsonException($"Value for {key} must be a number");
|
||||
|
||||
hasXYZ = true;
|
||||
data[i] = reader.GetInt32();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i == 3)
|
||||
{
|
||||
if (hasXYZ)
|
||||
throw new JsonException("WorldLocation must have loc or x, y, z, but not both");
|
||||
|
||||
hasLoc = true;
|
||||
var loc = new Point3DConverter().Read(ref reader, typeof(Point3D), options);
|
||||
data[0] = loc.X;
|
||||
data[1] = loc.Y;
|
||||
data[2] = loc.Z;
|
||||
count = 3;
|
||||
continue;
|
||||
}
|
||||
|
||||
map = reader.TokenType switch
|
||||
{
|
||||
JsonTokenType.String => Map.Parse(reader.GetString()),
|
||||
JsonTokenType.Number => Map.Maps[reader.GetInt32()],
|
||||
_ => throw new JsonException($"Value for {key} must be a number or string")
|
||||
};
|
||||
}
|
||||
|
||||
if (!hasMap || count < 2)
|
||||
throw new JsonException("WorldLocation must have an x, y, z, and map properties");
|
||||
|
||||
return new WorldLocation(data[0], data[1], data[2], map);
|
||||
}
|
||||
|
||||
public override WorldLocation Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) =>
|
||||
reader.TokenType switch
|
||||
{
|
||||
JsonTokenType.StartArray => DeserializeArray(ref reader),
|
||||
JsonTokenType.StartObject => DeserializeObj(ref reader, options),
|
||||
_ => throw new JsonException("Invalid Json for Point3D")
|
||||
};
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, WorldLocation value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStartArray();
|
||||
writer.WriteNumberValue(value.X);
|
||||
writer.WriteNumberValue(value.Y);
|
||||
writer.WriteNumberValue(value.Z);
|
||||
writer.WriteStringValue(value.Map.ToString());
|
||||
writer.WriteEndArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,34 +1,35 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: WorldLocationConverterFactory.cs *
|
||||
* Created: 2020/05/31 - Updated: 2020/05/31 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class WorldLocationConverterFactory : JsonConverterFactory
|
||||
{
|
||||
public override bool CanConvert(Type typeToConvert) => typeToConvert == typeof(WorldLocation);
|
||||
|
||||
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options) => new WorldLocationConverter();
|
||||
}
|
||||
}
|
||||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: WorldLocationConverterFactory.cs *
|
||||
* Created: 2020/05/31 - Updated: 2020/05/31 *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class WorldLocationConverterFactory : JsonConverterFactory
|
||||
{
|
||||
public override bool CanConvert(Type typeToConvert) => typeToConvert == typeof(WorldLocation);
|
||||
|
||||
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options) =>
|
||||
new WorldLocationConverter();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue