2020-02-27 18:56:49 +01:00
|
|
|
using System;
|
|
|
|
using MLEM.Misc;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
|
namespace MLEM.Data.Json {
|
2020-05-22 20:32:38 +02:00
|
|
|
/// <inheritdoc />
|
2020-02-27 18:56:49 +01:00
|
|
|
public class Direction2Converter : JsonConverter<Direction2> {
|
|
|
|
|
2020-05-22 20:32:38 +02:00
|
|
|
/// <inheritdoc />
|
2020-02-27 18:56:49 +01:00
|
|
|
public override void WriteJson(JsonWriter writer, Direction2 value, JsonSerializer serializer) {
|
|
|
|
writer.WriteValue(value.ToString());
|
|
|
|
}
|
|
|
|
|
2020-05-22 20:32:38 +02:00
|
|
|
/// <inheritdoc />
|
2020-02-27 18:56:49 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|