mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-23 05:08:34 +01:00
20 lines
No EOL
651 B
C#
20 lines
No EOL
651 B
C#
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)))
|
|
.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;
|
|
}
|
|
|
|
}
|
|
} |