using System;
using System.Linq;
using Newtonsoft.Json;
namespace MLEM.Data.Json {
///
/// A helper class that stores all of the types that are part of MLEM.Data.
///
public class JsonConverters {
///
/// An array of all of the s that are part of MLEM.Data
///
public static readonly JsonConverter[] Converters = typeof(JsonConverters).Assembly.GetExportedTypes()
.Where(t => t.IsSubclassOf(typeof(JsonConverter)) && !t.IsGenericType)
.Select(Activator.CreateInstance).Cast().ToArray();
///
/// Adds all of the objects that are part of MLEM.Data to the given
///
/// The serializer to add the converters to
/// The given serializer, for chaining
public static JsonSerializer AddAll(JsonSerializer serializer) {
foreach (var converter in JsonConverters.Converters)
serializer.Converters.Add(converter);
return serializer;
}
}
}