IW4M-Admin/SharedLibraryCore/Helpers/BuildNumberJsonConverter.cs
2022-01-26 15:26:25 -06:00

27 lines
751 B
C#

using System;
using Newtonsoft.Json;
namespace SharedLibraryCore.Helpers
{
/// <summary>
/// JSON converter for the build number
/// </summary>
public class BuildNumberJsonConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
return objectType == typeof(string);
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue,
JsonSerializer serializer)
{
return BuildNumber.Parse(reader.Value.ToString());
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
writer.WriteValue(value.ToString());
}
}
}