mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-15 20:20:25 +01:00
Added a precompiled protobuf serializer assembly
This commit is contained in:
parent
50f88997ba
commit
e6d689bdd3
@@ -1,17 +1,29 @@
|
||||
using System;
|
||||
using ServiceStack.Text;
|
||||
using System;
|
||||
using System.IO;
|
||||
using ProtoBuf;
|
||||
using ServiceStack.Text;
|
||||
|
||||
namespace MediaBrowser.ApiInteraction
|
||||
{
|
||||
public static class DataSerializer
|
||||
{
|
||||
/// <summary>
|
||||
/// This is an auto-generated Protobuf Serialization assembly for best performance.
|
||||
/// It is created during the Model project's post-build event.
|
||||
/// This means that this class can currently only handle types within the Model project.
|
||||
/// If we need to, we can always add a param indicating whether or not the model serializer should be used.
|
||||
/// </summary>
|
||||
private static ProtobufModelSerializer ProtobufModelSerializer = new ProtobufModelSerializer();
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes an object using generics
|
||||
/// </summary>
|
||||
public static T DeserializeFromStream<T>(Stream stream, SerializationFormats format)
|
||||
where T : class
|
||||
{
|
||||
if (format == ApiInteraction.SerializationFormats.Protobuf)
|
||||
{
|
||||
return Serializer.Deserialize<T>(stream);
|
||||
//return Serializer.Deserialize<T>(stream);
|
||||
return ProtobufModelSerializer.Deserialize(stream, null, typeof(T)) as T;
|
||||
}
|
||||
else if (format == ApiInteraction.SerializationFormats.Jsv)
|
||||
{
|
||||
@@ -25,11 +37,15 @@ namespace MediaBrowser.ApiInteraction
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes an object
|
||||
/// </summary>
|
||||
public static object DeserializeFromStream(Stream stream, SerializationFormats format, Type type)
|
||||
{
|
||||
if (format == ApiInteraction.SerializationFormats.Protobuf)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
//throw new NotImplementedException();
|
||||
return ProtobufModelSerializer.Deserialize(stream, null, type);
|
||||
}
|
||||
else if (format == ApiInteraction.SerializationFormats.Jsv)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user