1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-26 22:48:34 +01:00
MLEM/MLEM.Data/Json/Direction2Converter.cs

18 lines
592 B
C#
Raw Normal View History

2020-02-27 18:56:49 +01:00
using System;
using MLEM.Misc;
using Newtonsoft.Json;
namespace MLEM.Data.Json {
public class Direction2Converter : JsonConverter<Direction2> {
public override void WriteJson(JsonWriter writer, Direction2 value, JsonSerializer serializer) {
writer.WriteValue(value.ToString());
}
public override Direction2 ReadJson(JsonReader reader, Type objectType, Direction2 existingValue, bool hasExistingValue, JsonSerializer serializer) {
Enum.TryParse<Direction2>(reader.Value.ToString(), out var dir);
return dir;
}
}
}