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
911 B
29 lines
911 B
using System;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace NzbDrone.Core.Download.Clients.NzbVortex.JsonConverters
|
|
{
|
|
public class NzbVortexLoginResultTypeConverter : JsonConverter
|
|
{
|
|
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
|
{
|
|
var priorityType = (NzbVortexLoginResultType)value;
|
|
writer.WriteValue(priorityType.ToString().ToLower());
|
|
}
|
|
|
|
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
|
{
|
|
var result = reader.Value.ToString().Replace("_", string.Empty);
|
|
|
|
Enum.TryParse(result, true, out NzbVortexLoginResultType output);
|
|
|
|
return output;
|
|
}
|
|
|
|
public override bool CanConvert(Type objectType)
|
|
{
|
|
return objectType == typeof(NzbVortexLoginResultType);
|
|
}
|
|
}
|
|
}
|