mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-21 17:59:31 +00:00
27 lines
931 B
C#
27 lines
931 B
C#
using System;
|
|
using System.Reflection;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
namespace MonoGame.Extended.Particles.Serialization
|
|
{
|
|
public class ModifierExecutionStrategyJsonConverter : JsonConverter
|
|
{
|
|
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
|
{
|
|
writer.WriteValue(value.ToString());
|
|
}
|
|
|
|
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
|
{
|
|
var value = JToken.Load(reader).ToObject<string>();
|
|
return ParticleModifierExecutionStrategy.Parse(value);
|
|
}
|
|
|
|
public override bool CanConvert(Type objectType)
|
|
{
|
|
return objectType == typeof(ParticleModifierExecutionStrategy)
|
|
|| objectType.GetTypeInfo().BaseType == typeof(ParticleModifierExecutionStrategy);
|
|
}
|
|
}
|
|
} |