Added Protobuf to BaseSerializationHandler

This commit is contained in:
LukePulverenti Luke Pulverenti luke pulverenti 2012-08-28 10:22:25 -04:00
parent 97bc7ec378
commit a0d69b3804
13 changed files with 22 additions and 16 deletions

View File

@ -12,7 +12,7 @@ namespace MediaBrowser.Api.HttpHandlers
/// <summary>
/// Gets a single genre
/// </summary>
public class GenreHandler : BaseJsonHandler<IBNItem>
public class GenreHandler : BaseSerializationHandler<IBNItem>
{
protected override Task<IBNItem> GetObjectToSerialize()
{

View File

@ -9,7 +9,7 @@ using MediaBrowser.Model.Entities;
namespace MediaBrowser.Api.HttpHandlers
{
public class GenresHandler : BaseJsonHandler<IEnumerable<IBNItem>>
public class GenresHandler : BaseSerializationHandler<IEnumerable<IBNItem>>
{
protected override Task<IEnumerable<IBNItem>> GetObjectToSerialize()
{

View File

@ -8,7 +8,7 @@ using MediaBrowser.Model.Entities;
namespace MediaBrowser.Api.HttpHandlers
{
public class ItemHandler : BaseJsonHandler<DTOBaseItem>
public class ItemHandler : BaseSerializationHandler<DTOBaseItem>
{
protected override Task<DTOBaseItem> GetObjectToSerialize()
{

View File

@ -9,7 +9,7 @@ using MediaBrowser.Model.Entities;
namespace MediaBrowser.Api.HttpHandlers
{
public class ItemListHandler : BaseJsonHandler<DTOBaseItem[]>
public class ItemListHandler : BaseSerializationHandler<DTOBaseItem[]>
{
protected override Task<DTOBaseItem[]> GetObjectToSerialize()
{

View File

@ -12,7 +12,7 @@ namespace MediaBrowser.Api.HttpHandlers
/// <summary>
/// Gets a single Person
/// </summary>
public class PersonHandler : BaseJsonHandler<IBNItem>
public class PersonHandler : BaseSerializationHandler<IBNItem>
{
protected override Task<IBNItem> GetObjectToSerialize()
{

View File

@ -7,7 +7,7 @@ using MediaBrowser.Model.Plugins;
namespace MediaBrowser.Api.HttpHandlers
{
public class PluginConfigurationHandler : BaseJsonHandler<BasePluginConfiguration>
public class PluginConfigurationHandler : BaseSerializationHandler<BasePluginConfiguration>
{
protected override Task<BasePluginConfiguration> GetObjectToSerialize()
{

View File

@ -10,7 +10,7 @@ namespace MediaBrowser.Api.HttpHandlers
/// <summary>
/// Provides information about installed plugins
/// </summary>
public class PluginsHandler : BaseJsonHandler<IEnumerable<PluginInfo>>
public class PluginsHandler : BaseSerializationHandler<IEnumerable<PluginInfo>>
{
protected override Task<IEnumerable<PluginInfo>> GetObjectToSerialize()
{

View File

@ -12,7 +12,7 @@ namespace MediaBrowser.Api.HttpHandlers
/// <summary>
/// Gets a single studio
/// </summary>
public class StudioHandler : BaseJsonHandler<IBNItem>
public class StudioHandler : BaseSerializationHandler<IBNItem>
{
protected override Task<IBNItem> GetObjectToSerialize()
{

View File

@ -9,7 +9,7 @@ using MediaBrowser.Model.Entities;
namespace MediaBrowser.Api.HttpHandlers
{
public class StudiosHandler : BaseJsonHandler<IEnumerable<IBNItem>>
public class StudiosHandler : BaseSerializationHandler<IEnumerable<IBNItem>>
{
protected override Task<IEnumerable<IBNItem>> GetObjectToSerialize()
{

View File

@ -6,7 +6,7 @@ using MediaBrowser.Model.Entities;
namespace MediaBrowser.Api.HttpHandlers
{
class UsersHandler : BaseJsonHandler<IEnumerable<User>>
class UsersHandler : BaseSerializationHandler<IEnumerable<User>>
{
protected override Task<IEnumerable<User>> GetObjectToSerialize()
{

View File

@ -12,7 +12,7 @@ namespace MediaBrowser.Api.HttpHandlers
/// <summary>
/// Gets a single year
/// </summary>
public class YearHandler : BaseJsonHandler<IBNItem>
public class YearHandler : BaseSerializationHandler<IBNItem>
{
protected override Task<IBNItem> GetObjectToSerialize()
{

View File

@ -9,7 +9,7 @@ using MediaBrowser.Model.Entities;
namespace MediaBrowser.Api.HttpHandlers
{
public class YearsHandler : BaseJsonHandler<IEnumerable<IBNItem>>
public class YearsHandler : BaseSerializationHandler<IEnumerable<IBNItem>>
{
protected override Task<IEnumerable<IBNItem>> GetObjectToSerialize()
{

View File

@ -1,11 +1,11 @@
using System.IO;
using System;
using System.IO;
using System.Threading.Tasks;
using MediaBrowser.Common.Serialization;
using System;
namespace MediaBrowser.Common.Net.Handlers
{
public abstract class BaseJsonHandler<T> : BaseHandler
public abstract class BaseSerializationHandler<T> : BaseHandler
{
public SerializationFormat SerializationFormat
{
@ -28,6 +28,8 @@ namespace MediaBrowser.Common.Net.Handlers
{
case Handlers.SerializationFormat.Jsv:
return Task.FromResult<string>("text/plain");
case Handlers.SerializationFormat.Protobuf:
return Task.FromResult<string>("application/x-protobuf");
default:
return Task.FromResult<string>(MimeTypes.JsonMimeType);
}
@ -67,6 +69,9 @@ namespace MediaBrowser.Common.Net.Handlers
case Handlers.SerializationFormat.Jsv:
JsvSerializer.SerializeToStream<T>(_ObjectToSerialize, stream);
break;
case Handlers.SerializationFormat.Protobuf:
ProtobufSerializer.SerializeToStream<T>(_ObjectToSerialize, stream);
break;
default:
JsonSerializer.SerializeToStream<T>(_ObjectToSerialize, stream);
break;
@ -77,7 +82,8 @@ namespace MediaBrowser.Common.Net.Handlers
public enum SerializationFormat
{
Json,
Jsv
Jsv,
Protobuf
}
}