2012-07-20 02:22:44 +00:00
|
|
|
|
using System.IO;
|
2012-08-11 18:07:07 +00:00
|
|
|
|
using System.Threading.Tasks;
|
2012-07-21 18:39:47 +00:00
|
|
|
|
using MediaBrowser.Common.Net.Handlers;
|
2012-07-31 16:29:07 +00:00
|
|
|
|
using MediaBrowser.Common.Serialization;
|
2012-07-20 02:22:44 +00:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Api.HttpHandlers
|
|
|
|
|
{
|
|
|
|
|
public abstract class JsonHandler : BaseJsonHandler
|
|
|
|
|
{
|
|
|
|
|
protected abstract object ObjectToSerialize { get; }
|
|
|
|
|
|
2012-08-11 18:07:07 +00:00
|
|
|
|
protected override Task WriteResponseToOutputStream(Stream stream)
|
2012-07-20 02:22:44 +00:00
|
|
|
|
{
|
2012-08-11 18:07:07 +00:00
|
|
|
|
return Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
JsonSerializer.SerializeToStream(ObjectToSerialize, stream);
|
|
|
|
|
});
|
2012-07-20 02:22:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|