1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-01 05:10:50 +01:00
MLEM/MLEM.Data/Json/JsonConverters.cs

38 lines
1.3 KiB
C#
Raw Permalink Normal View History

2020-02-27 18:56:49 +01:00
using System;
using System.Linq;
using Newtonsoft.Json;
namespace MLEM.Data.Json {
/// <summary>
/// A helper class that stores all of the <see cref="JsonConverter"/> types that are part of MLEM.Data.
/// </summary>
2020-02-27 18:56:49 +01:00
public class JsonConverters {
/// <summary>
/// An array of all of the <see cref="JsonConverter"/>s that are part of MLEM.Data
/// </summary>
public static readonly JsonConverter[] Converters = {
new Direction2Converter(),
2022-12-13 13:11:36 +01:00
#pragma warning disable CS0618
new DynamicEnumConverter(),
2022-12-13 13:11:36 +01:00
#pragma warning restore CS0618
new PointConverter(),
new RectangleConverter(),
new RectangleFConverter(),
new Vector2Converter()
};
2020-02-27 18:56:49 +01:00
/// <summary>
/// Adds all of the <see cref="JsonConverter"/> objects that are part of MLEM.Data to the given <see cref="JsonSerializer"/>
/// </summary>
/// <param name="serializer">The serializer to add the converters to</param>
/// <returns>The given serializer, for chaining</returns>
2020-02-27 18:56:49 +01:00
public static JsonSerializer AddAll(JsonSerializer serializer) {
foreach (var converter in JsonConverters.Converters)
2020-02-27 18:56:49 +01:00
serializer.Converters.Add(converter);
return serializer;
}
}
2022-06-17 18:23:47 +02:00
}