2021-04-26 20:56:38 +00:00
|
|
|
using System.Collections.Generic;
|
2013-01-25 19:03:28 +00:00
|
|
|
using System.IO;
|
2021-04-26 20:56:38 +00:00
|
|
|
using System.Text.Json;
|
2013-01-25 19:03:28 +00:00
|
|
|
using Nancy;
|
2019-09-12 20:32:51 +00:00
|
|
|
using Nancy.Responses.Negotiation;
|
2013-05-12 15:18:17 +00:00
|
|
|
using NzbDrone.Common.Serializer;
|
2013-01-25 19:03:28 +00:00
|
|
|
|
2017-09-04 02:20:56 +00:00
|
|
|
namespace Lidarr.Http.Extensions
|
2013-01-25 19:03:28 +00:00
|
|
|
{
|
|
|
|
public class NancyJsonSerializer : ISerializer
|
|
|
|
{
|
2021-04-26 20:56:38 +00:00
|
|
|
protected readonly JsonSerializerOptions _serializerSettings;
|
|
|
|
|
|
|
|
public NancyJsonSerializer()
|
|
|
|
{
|
|
|
|
_serializerSettings = STJson.GetSerializerSettings();
|
|
|
|
}
|
|
|
|
|
2019-09-12 20:32:51 +00:00
|
|
|
public bool CanSerialize(MediaRange contentType)
|
2013-01-25 19:03:28 +00:00
|
|
|
{
|
2019-09-12 20:32:51 +00:00
|
|
|
return contentType == "application/json";
|
2013-01-25 19:03:28 +00:00
|
|
|
}
|
|
|
|
|
2019-09-12 20:32:51 +00:00
|
|
|
public void Serialize<TModel>(MediaRange contentType, TModel model, Stream outputStream)
|
2013-01-25 19:03:28 +00:00
|
|
|
{
|
2021-04-26 20:56:38 +00:00
|
|
|
STJson.Serialize(model, outputStream, _serializerSettings);
|
2013-01-25 19:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public IEnumerable<string> Extensions { get; private set; }
|
|
|
|
}
|
2019-09-12 20:32:51 +00:00
|
|
|
}
|