diff options
| author | LukePulverenti Luke Pulverenti luke pulverenti <LukePulverenti Luke Pulverenti luke.pulverenti@gmail.com> | 2012-09-09 01:30:07 -0400 |
|---|---|---|
| committer | LukePulverenti Luke Pulverenti luke pulverenti <LukePulverenti Luke Pulverenti luke.pulverenti@gmail.com> | 2012-09-09 01:30:07 -0400 |
| commit | e6d689bdd3429cd5017de355093ee9c2f3fad069 (patch) | |
| tree | 75e6c4eef0bb48ceae70ea802cb36a6073c2f218 /MediaBrowser.ApiInteraction.Metro/DataSerializer.cs | |
| parent | 50f88997bab58f4cfcbd3f420521776a54eb372d (diff) | |
Added a precompiled protobuf serializer assembly
Diffstat (limited to 'MediaBrowser.ApiInteraction.Metro/DataSerializer.cs')
| -rw-r--r-- | MediaBrowser.ApiInteraction.Metro/DataSerializer.cs | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/MediaBrowser.ApiInteraction.Metro/DataSerializer.cs b/MediaBrowser.ApiInteraction.Metro/DataSerializer.cs index 8af88014c..6445e8567 100644 --- a/MediaBrowser.ApiInteraction.Metro/DataSerializer.cs +++ b/MediaBrowser.ApiInteraction.Metro/DataSerializer.cs @@ -1,17 +1,26 @@ -using System;
+using Newtonsoft.Json;
+using System;
using System.IO;
-using Newtonsoft.Json;
-using ProtoBuf;
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();
+
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)
{
@@ -35,7 +44,8 @@ namespace MediaBrowser.ApiInteraction {
if (format == ApiInteraction.SerializationFormats.Protobuf)
{
- throw new NotImplementedException();
+ //throw new NotImplementedException();
+ return ProtobufModelSerializer.Deserialize(stream, null, type);
}
else if (format == ApiInteraction.SerializationFormats.Jsv)
{
|
