You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

20 lines
735 B

#nullable enable
using System;
using System.Runtime.Remoting.Messaging;
using Hive.Versioning;
using Newtonsoft.Json;
namespace IPA.JsonConverters
{
internal class SemverRangeConverter : JsonConverter<VersionRange?>
{
public override VersionRange? ReadJson(JsonReader reader, Type objectType, VersionRange? existingValue, bool hasExistingValue, JsonSerializer serializer)
=> reader.Value is not string s ? existingValue : new VersionRange(s);
public override void WriteJson(JsonWriter writer, VersionRange? value, JsonSerializer serializer)
{
if (value is null) writer.WriteNull();
else writer.WriteValue(value.ToString());
}
}
}