Innovenergy_trunk/csharp/Lib/Units/Json/PowerConverter.cs

17 lines
481 B
C#
Raw Normal View History

2023-02-23 12:53:39 +00:00
using System.Text.Json;
using System.Text.Json.Serialization;
namespace InnovEnergy.Lib.Units.Json;
2023-02-23 12:53:39 +00:00
public class PowerConverter : JsonConverter<Power>
{
public override Power Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
return new Power(reader.GetDecimal());
}
public override void Write(Utf8JsonWriter writer, Power value, JsonSerializerOptions options)
{
writer.WriteNumberValue(value.Value);
}
}