2021-09-27 12:42:46 +00:00
|
|
|
using System;
|
|
|
|
using System.Text.Json;
|
|
|
|
using System.Text.Json.Serialization;
|
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
namespace Wabbajack.DTOs.JsonConverters;
|
|
|
|
|
|
|
|
public class VersionConverter : JsonConverter<Version>
|
2021-09-27 12:42:46 +00:00
|
|
|
{
|
2021-10-23 16:51:17 +00:00
|
|
|
public override Version? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
2021-09-27 12:42:46 +00:00
|
|
|
{
|
2021-10-23 16:51:17 +00:00
|
|
|
return new Version(reader.GetString()!);
|
|
|
|
}
|
2021-09-27 12:42:46 +00:00
|
|
|
|
2021-10-23 16:51:17 +00:00
|
|
|
public override void Write(Utf8JsonWriter writer, Version value, JsonSerializerOptions options)
|
|
|
|
{
|
|
|
|
writer.WriteStringValue(value.ToString());
|
2021-09-27 12:42:46 +00:00
|
|
|
}
|
|
|
|
}
|