1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-26 17:57:43 +00:00
Sonarr/NzbDrone.Api/SignalR/Serializer.cs
2013-05-29 18:33:20 -07:00

29 lines
No EOL
771 B
C#

using System;
using System.IO;
using Microsoft.AspNet.SignalR.Json;
using NzbDrone.Common.Serializer;
namespace NzbDrone.Api.SignalR
{
public class Serializer : IJsonSerializer
{
private readonly JsonNetSerializer _signalRSerializer = new JsonNetSerializer();
public void Serialize(object value, TextWriter writer)
{
if (value.GetType().FullName.StartsWith("NzbDrone"))
{
Json.Serialize(value, writer);
}
else
{
_signalRSerializer.Serialize(value, writer);
}
}
public object Parse(TextReader reader, Type targetType)
{
return Json.Deserialize(reader.ReadToEnd(), targetType);
}
}
}