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

20 lines
651 B
C#
Raw Normal View History

2020-02-27 18:56:49 +01:00
using System;
using System.Linq;
using System.Reflection;
using Newtonsoft.Json;
namespace MLEM.Data.Json {
public class JsonConverters {
public static readonly JsonConverter[] Converters = typeof(JsonConverters).Assembly.GetExportedTypes()
.Where(t => t.IsSubclassOf(typeof(JsonConverter)))
2020-02-27 18:56:49 +01:00
.Select(t => t.GetConstructor(Type.EmptyTypes).Invoke(null)).Cast<JsonConverter>().ToArray();
public static JsonSerializer AddAll(JsonSerializer serializer) {
foreach (var converter in Converters)
serializer.Converters.Add(converter);
return serializer;
}
}
}