Files
crtr/Assets/Cryville/Crtr/JsonPdtExpConverter.cs

20 lines
653 B
C#

using Cryville.Common.Pdt;
using Newtonsoft.Json;
using System;
namespace Cryville.Crtr {
public class JsonPdtExpConverter : JsonConverter<PdtExpression> {
static readonly PdtFragmentInterpreter _itor = new();
public override PdtExpression ReadJson(JsonReader reader, Type objectType, PdtExpression existingValue, bool hasExistingValue, JsonSerializer serializer) {
_itor.SetSource((string)reader.Value);
return _itor.GetExp();
}
public override void WriteJson(JsonWriter writer, PdtExpression value, JsonSerializer serializer) {
throw new NotSupportedException();
}
public override bool CanWrite { get { return false; } }
}
}