1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-28 10:48:46 +00:00
Sonarr/NzbDrone.Services.Api/Extensions/NancyJsonSerializer.cs
Mark McDowall b7575e05c1 Json.net instead of ServiceStack
More DailySeries repo work done
2013-02-15 16:52:38 -08:00

27 lines
No EOL
777 B
C#

using System.Collections.Generic;
using System.IO;
using System.Linq;
using Nancy;
using Newtonsoft.Json;
namespace NzbDrone.Services.Api.Extensions
{
public class NancyJsonSerializer : ISerializer
{
public readonly static NancyJsonSerializer Instance = new NancyJsonSerializer();
public bool CanSerialize(string contentType)
{
return true;
}
public void Serialize<TModel>(string contentType, TModel model, Stream outputStream)
{
var jsonTextWriter = new JsonTextWriter(new StreamWriter(outputStream));
Serializer.Instance.Serialize(jsonTextWriter, model);
jsonTextWriter.Flush();
}
public IEnumerable<string> Extensions { get; private set; }
}
}