mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 19:37:55 +02:00
Added Protobuf to BaseSerializationHandler
This commit is contained in:
parent
97bc7ec378
commit
a0d69b3804
13 changed files with 22 additions and 16 deletions
|
@ -12,7 +12,7 @@ namespace MediaBrowser.Api.HttpHandlers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a single genre
|
/// Gets a single genre
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class GenreHandler : BaseJsonHandler<IBNItem>
|
public class GenreHandler : BaseSerializationHandler<IBNItem>
|
||||||
{
|
{
|
||||||
protected override Task<IBNItem> GetObjectToSerialize()
|
protected override Task<IBNItem> GetObjectToSerialize()
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,7 @@ using MediaBrowser.Model.Entities;
|
||||||
|
|
||||||
namespace MediaBrowser.Api.HttpHandlers
|
namespace MediaBrowser.Api.HttpHandlers
|
||||||
{
|
{
|
||||||
public class GenresHandler : BaseJsonHandler<IEnumerable<IBNItem>>
|
public class GenresHandler : BaseSerializationHandler<IEnumerable<IBNItem>>
|
||||||
{
|
{
|
||||||
protected override Task<IEnumerable<IBNItem>> GetObjectToSerialize()
|
protected override Task<IEnumerable<IBNItem>> GetObjectToSerialize()
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,7 +8,7 @@ using MediaBrowser.Model.Entities;
|
||||||
|
|
||||||
namespace MediaBrowser.Api.HttpHandlers
|
namespace MediaBrowser.Api.HttpHandlers
|
||||||
{
|
{
|
||||||
public class ItemHandler : BaseJsonHandler<DTOBaseItem>
|
public class ItemHandler : BaseSerializationHandler<DTOBaseItem>
|
||||||
{
|
{
|
||||||
protected override Task<DTOBaseItem> GetObjectToSerialize()
|
protected override Task<DTOBaseItem> GetObjectToSerialize()
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,7 @@ using MediaBrowser.Model.Entities;
|
||||||
|
|
||||||
namespace MediaBrowser.Api.HttpHandlers
|
namespace MediaBrowser.Api.HttpHandlers
|
||||||
{
|
{
|
||||||
public class ItemListHandler : BaseJsonHandler<DTOBaseItem[]>
|
public class ItemListHandler : BaseSerializationHandler<DTOBaseItem[]>
|
||||||
{
|
{
|
||||||
protected override Task<DTOBaseItem[]> GetObjectToSerialize()
|
protected override Task<DTOBaseItem[]> GetObjectToSerialize()
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace MediaBrowser.Api.HttpHandlers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a single Person
|
/// Gets a single Person
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PersonHandler : BaseJsonHandler<IBNItem>
|
public class PersonHandler : BaseSerializationHandler<IBNItem>
|
||||||
{
|
{
|
||||||
protected override Task<IBNItem> GetObjectToSerialize()
|
protected override Task<IBNItem> GetObjectToSerialize()
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,7 +7,7 @@ using MediaBrowser.Model.Plugins;
|
||||||
|
|
||||||
namespace MediaBrowser.Api.HttpHandlers
|
namespace MediaBrowser.Api.HttpHandlers
|
||||||
{
|
{
|
||||||
public class PluginConfigurationHandler : BaseJsonHandler<BasePluginConfiguration>
|
public class PluginConfigurationHandler : BaseSerializationHandler<BasePluginConfiguration>
|
||||||
{
|
{
|
||||||
protected override Task<BasePluginConfiguration> GetObjectToSerialize()
|
protected override Task<BasePluginConfiguration> GetObjectToSerialize()
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace MediaBrowser.Api.HttpHandlers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provides information about installed plugins
|
/// Provides information about installed plugins
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PluginsHandler : BaseJsonHandler<IEnumerable<PluginInfo>>
|
public class PluginsHandler : BaseSerializationHandler<IEnumerable<PluginInfo>>
|
||||||
{
|
{
|
||||||
protected override Task<IEnumerable<PluginInfo>> GetObjectToSerialize()
|
protected override Task<IEnumerable<PluginInfo>> GetObjectToSerialize()
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace MediaBrowser.Api.HttpHandlers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a single studio
|
/// Gets a single studio
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class StudioHandler : BaseJsonHandler<IBNItem>
|
public class StudioHandler : BaseSerializationHandler<IBNItem>
|
||||||
{
|
{
|
||||||
protected override Task<IBNItem> GetObjectToSerialize()
|
protected override Task<IBNItem> GetObjectToSerialize()
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,7 @@ using MediaBrowser.Model.Entities;
|
||||||
|
|
||||||
namespace MediaBrowser.Api.HttpHandlers
|
namespace MediaBrowser.Api.HttpHandlers
|
||||||
{
|
{
|
||||||
public class StudiosHandler : BaseJsonHandler<IEnumerable<IBNItem>>
|
public class StudiosHandler : BaseSerializationHandler<IEnumerable<IBNItem>>
|
||||||
{
|
{
|
||||||
protected override Task<IEnumerable<IBNItem>> GetObjectToSerialize()
|
protected override Task<IEnumerable<IBNItem>> GetObjectToSerialize()
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,7 +6,7 @@ using MediaBrowser.Model.Entities;
|
||||||
|
|
||||||
namespace MediaBrowser.Api.HttpHandlers
|
namespace MediaBrowser.Api.HttpHandlers
|
||||||
{
|
{
|
||||||
class UsersHandler : BaseJsonHandler<IEnumerable<User>>
|
class UsersHandler : BaseSerializationHandler<IEnumerable<User>>
|
||||||
{
|
{
|
||||||
protected override Task<IEnumerable<User>> GetObjectToSerialize()
|
protected override Task<IEnumerable<User>> GetObjectToSerialize()
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace MediaBrowser.Api.HttpHandlers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a single year
|
/// Gets a single year
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class YearHandler : BaseJsonHandler<IBNItem>
|
public class YearHandler : BaseSerializationHandler<IBNItem>
|
||||||
{
|
{
|
||||||
protected override Task<IBNItem> GetObjectToSerialize()
|
protected override Task<IBNItem> GetObjectToSerialize()
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,7 @@ using MediaBrowser.Model.Entities;
|
||||||
|
|
||||||
namespace MediaBrowser.Api.HttpHandlers
|
namespace MediaBrowser.Api.HttpHandlers
|
||||||
{
|
{
|
||||||
public class YearsHandler : BaseJsonHandler<IEnumerable<IBNItem>>
|
public class YearsHandler : BaseSerializationHandler<IEnumerable<IBNItem>>
|
||||||
{
|
{
|
||||||
protected override Task<IEnumerable<IBNItem>> GetObjectToSerialize()
|
protected override Task<IEnumerable<IBNItem>> GetObjectToSerialize()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
using System.IO;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Common.Serialization;
|
using MediaBrowser.Common.Serialization;
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Net.Handlers
|
namespace MediaBrowser.Common.Net.Handlers
|
||||||
{
|
{
|
||||||
public abstract class BaseJsonHandler<T> : BaseHandler
|
public abstract class BaseSerializationHandler<T> : BaseHandler
|
||||||
{
|
{
|
||||||
public SerializationFormat SerializationFormat
|
public SerializationFormat SerializationFormat
|
||||||
{
|
{
|
||||||
|
@ -28,6 +28,8 @@ namespace MediaBrowser.Common.Net.Handlers
|
||||||
{
|
{
|
||||||
case Handlers.SerializationFormat.Jsv:
|
case Handlers.SerializationFormat.Jsv:
|
||||||
return Task.FromResult<string>("text/plain");
|
return Task.FromResult<string>("text/plain");
|
||||||
|
case Handlers.SerializationFormat.Protobuf:
|
||||||
|
return Task.FromResult<string>("application/x-protobuf");
|
||||||
default:
|
default:
|
||||||
return Task.FromResult<string>(MimeTypes.JsonMimeType);
|
return Task.FromResult<string>(MimeTypes.JsonMimeType);
|
||||||
}
|
}
|
||||||
|
@ -67,6 +69,9 @@ namespace MediaBrowser.Common.Net.Handlers
|
||||||
case Handlers.SerializationFormat.Jsv:
|
case Handlers.SerializationFormat.Jsv:
|
||||||
JsvSerializer.SerializeToStream<T>(_ObjectToSerialize, stream);
|
JsvSerializer.SerializeToStream<T>(_ObjectToSerialize, stream);
|
||||||
break;
|
break;
|
||||||
|
case Handlers.SerializationFormat.Protobuf:
|
||||||
|
ProtobufSerializer.SerializeToStream<T>(_ObjectToSerialize, stream);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
JsonSerializer.SerializeToStream<T>(_ObjectToSerialize, stream);
|
JsonSerializer.SerializeToStream<T>(_ObjectToSerialize, stream);
|
||||||
break;
|
break;
|
||||||
|
@ -77,7 +82,8 @@ namespace MediaBrowser.Common.Net.Handlers
|
||||||
public enum SerializationFormat
|
public enum SerializationFormat
|
||||||
{
|
{
|
||||||
Json,
|
Json,
|
||||||
Jsv
|
Jsv,
|
||||||
|
Protobuf
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue