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.
Sonarr/src/NzbDrone.Common/Serializer/Newtonsoft.Json/HttpUriConverter.cs

32 lines
845 B

using System;
using Newtonsoft.Json;
using NzbDrone.Common.Http;
namespace NzbDrone.Common.Serializer
{
public class HttpUriConverter : JsonConverter
{
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (value == null)
{
writer.WriteNull();
}
else if (value is HttpUri)
{
writer.WriteValue((value as HttpUri).FullUri);
}
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
return new HttpUri(reader.ReadAsString());
}
public override bool CanConvert(Type objectType)
{
return objectType == typeof(HttpUri);
}
}
}