2013-01-25 19:03:28 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using Nancy;
|
2013-04-17 00:24:49 +00:00
|
|
|
|
using NzbDrone.Common;
|
2013-05-12 15:18:17 +00:00
|
|
|
|
using NzbDrone.Common.Serializer;
|
2013-01-25 19:03:28 +00:00
|
|
|
|
|
2013-02-23 20:35:26 +00:00
|
|
|
|
namespace NzbDrone.Api.Extensions
|
2013-01-25 19:03:28 +00:00
|
|
|
|
{
|
|
|
|
|
public class NancyJsonSerializer : ISerializer
|
|
|
|
|
{
|
2013-04-17 00:24:49 +00:00
|
|
|
|
private readonly IJsonSerializer _jsonSerializer;
|
|
|
|
|
|
|
|
|
|
public NancyJsonSerializer(IJsonSerializer jsonSerializer)
|
|
|
|
|
{
|
|
|
|
|
_jsonSerializer = jsonSerializer;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-25 19:03:28 +00:00
|
|
|
|
|
|
|
|
|
public bool CanSerialize(string contentType)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Serialize<TModel>(string contentType, TModel model, Stream outputStream)
|
|
|
|
|
{
|
2013-04-17 00:24:49 +00:00
|
|
|
|
_jsonSerializer.Serialize(model, outputStream);
|
2013-01-25 19:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IEnumerable<string> Extensions { get; private set; }
|
|
|
|
|
}
|
|
|
|
|
}
|