mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
24 lines
709 B
C#
24 lines
709 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.Text;
|
|
using Newtonsoft.Json;
|
|
using Wabbajack.Common;
|
|
|
|
namespace Wabbajack
|
|
{
|
|
public class PercentJsonConverter : JsonConverter<Percent>
|
|
{
|
|
public override Percent ReadJson(JsonReader reader, Type objectType, [AllowNull] Percent existingValue, bool hasExistingValue, JsonSerializer serializer)
|
|
{
|
|
double d = (double)reader.Value;
|
|
return Percent.FactoryPutInRange(d);
|
|
}
|
|
|
|
public override void WriteJson(JsonWriter writer, [AllowNull] Percent value, JsonSerializer serializer)
|
|
{
|
|
writer.WriteValue(value.Value);
|
|
}
|
|
}
|
|
}
|