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 {
|
|
|
|
|
2020-02-27 19:43:36 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|