|
@@ -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
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|