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.
 
 
 
 

16 lines
643 B

#nullable enable
using System;
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 string s && VersionRange.TryParse(s, out var range) ? range : existingValue;
public override void WriteJson(JsonWriter writer, VersionRange? value, JsonSerializer serializer)
=> writer.WriteValue(value?.ToString());
}
}