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.
 
 
 
 

29 lines
950 B

using IPA.Updating.ModsaberML;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static IPA.Updating.ModsaberML.ApiEndpoint.Mod;
namespace IPA.Updating.Converters
{
internal class ModsaberDependencyConverter : JsonConverter<Dependency>
{
public override Dependency ReadJson(JsonReader reader, Type objectType, Dependency existingValue, bool hasExistingValue, JsonSerializer serializer)
{
var parts = (reader.Value as string).Split('@');
return new Dependency()
{
Name = parts[0],
VersionRange = new SemVer.Range(parts[1])
};
}
public override void WriteJson(JsonWriter writer, Dependency value, JsonSerializer serializer)
{
writer.WriteValue($"{value.Name}@{value.VersionRange.ToString()}");
}
}
}