1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-05 10:32:35 +01:00
Radarr/NzbDrone.Api/SignalR/Serializer.cs

29 lines
771 B
C#
Raw Normal View History

using System;
using System.IO;
using Microsoft.AspNet.SignalR.Json;
2013-05-13 04:52:55 +02:00
using NzbDrone.Common.Serializer;
namespace NzbDrone.Api.SignalR
{
public class Serializer : IJsonSerializer
{
2013-05-13 04:52:55 +02:00
private readonly JsonNetSerializer _signalRSerializer = new JsonNetSerializer();
public void Serialize(object value, TextWriter writer)
{
if (value.GetType().FullName.StartsWith("NzbDrone"))
{
2013-05-13 04:52:55 +02:00
Json.Serialize(value, writer);
}
else
{
_signalRSerializer.Serialize(value, writer);
}
}
2013-05-24 03:41:17 +02:00
public object Parse(TextReader reader, Type targetType)
{
2013-05-24 03:41:17 +02:00
return Json.Deserialize(reader.ReadToEnd(), targetType);
}
}
}