mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-28 21:06:32 +01:00
Made a separate ApiInteraction solution with platform-specific builds
This commit is contained in:
parent
5dd7080084
commit
0fb0d52a4c
49
MediaBrowser.ApiInteraction/DataSerializer.cs
Normal file
49
MediaBrowser.ApiInteraction/DataSerializer.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using ProtoBuf;
|
||||
using ServiceStack.Text;
|
||||
|
||||
namespace MediaBrowser.ApiInteraction
|
||||
{
|
||||
public static class DataSerializer
|
||||
{
|
||||
public static T DeserializeJsonFromStream<T>(Stream stream)
|
||||
{
|
||||
return JsonSerializer.DeserializeFromStream<T>(stream);
|
||||
}
|
||||
|
||||
public static T DeserializeJsvFromStream<T>(Stream stream)
|
||||
{
|
||||
return TypeSerializer.DeserializeFromStream<T>(stream);
|
||||
}
|
||||
|
||||
public static object DeserializeJsvFromStream(Stream stream, Type type)
|
||||
{
|
||||
return TypeSerializer.DeserializeFromStream(type, stream);
|
||||
}
|
||||
|
||||
public static object DeserializeJsonFromStream(Stream stream, Type type)
|
||||
{
|
||||
return JsonSerializer.DeserializeFromStream(type, stream);
|
||||
}
|
||||
|
||||
public static T DeserializeProtobufFromStream<T>(Stream stream)
|
||||
{
|
||||
return Serializer.Deserialize<T>(stream);
|
||||
}
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
JsConfig.DateHandler = ServiceStack.Text.JsonDateHandler.ISO8601;
|
||||
JsConfig.ExcludeTypeInfo = true;
|
||||
JsConfig.IncludeNullValues = false;
|
||||
}
|
||||
}
|
||||
|
||||
public enum SerializationFormat
|
||||
{
|
||||
Json,
|
||||
Jsv,
|
||||
Protobuf
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user