diff options
Diffstat (limited to 'MediaBrowser.ApiInteraction.Metro')
4 files changed, 194 insertions, 0 deletions
diff --git a/MediaBrowser.ApiInteraction.Metro/ApiClient.cs b/MediaBrowser.ApiInteraction.Metro/ApiClient.cs new file mode 100644 index 0000000000..bf49a896ee --- /dev/null +++ b/MediaBrowser.ApiInteraction.Metro/ApiClient.cs @@ -0,0 +1,12 @@ +using System.Net.Http;
+
+namespace MediaBrowser.ApiInteraction
+{
+ public class ApiClient : BaseHttpApiClient
+ {
+ public ApiClient(HttpClientHandler handler)
+ : base(handler)
+ {
+ }
+ }
+}
diff --git a/MediaBrowser.ApiInteraction.Metro/DataSerializer.cs b/MediaBrowser.ApiInteraction.Metro/DataSerializer.cs new file mode 100644 index 0000000000..92e3f7c2b7 --- /dev/null +++ b/MediaBrowser.ApiInteraction.Metro/DataSerializer.cs @@ -0,0 +1,78 @@ +using Newtonsoft.Json;
+using System;
+using System.IO;
+
+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 readonly ProtobufModelSerializer ProtobufModelSerializer = new ProtobufModelSerializer();
+
+ public static T DeserializeFromStream<T>(Stream stream, SerializationFormats format)
+ where T : class
+ {
+ if (format == ApiInteraction.SerializationFormats.Protobuf)
+ {
+ return ProtobufModelSerializer.Deserialize(stream, null, typeof(T)) as T;
+ }
+ else if (format == ApiInteraction.SerializationFormats.Jsv)
+ {
+ throw new NotImplementedException();
+ }
+ else if (format == ApiInteraction.SerializationFormats.Json)
+ {
+ using (StreamReader streamReader = new StreamReader(stream))
+ {
+ using (JsonReader jsonReader = new JsonTextReader(streamReader))
+ {
+ return JsonSerializer.Create(new JsonSerializerSettings()).Deserialize<T>(jsonReader);
+ }
+ }
+ }
+
+ throw new NotImplementedException();
+ }
+
+ public static object DeserializeFromStream(Stream stream, SerializationFormats format, Type type)
+ {
+ if (format == ApiInteraction.SerializationFormats.Protobuf)
+ {
+ return ProtobufModelSerializer.Deserialize(stream, null, type);
+ }
+ else if (format == ApiInteraction.SerializationFormats.Jsv)
+ {
+ throw new NotImplementedException();
+ }
+ else if (format == ApiInteraction.SerializationFormats.Json)
+ {
+ using (StreamReader streamReader = new StreamReader(stream))
+ {
+ using (JsonReader jsonReader = new JsonTextReader(streamReader))
+ {
+ return JsonSerializer.Create(new JsonSerializerSettings()).Deserialize(jsonReader, type);
+ }
+ }
+ }
+
+ throw new NotImplementedException();
+ }
+
+ public static void Configure()
+ {
+ }
+
+ public static bool CanDeSerializeJsv
+ {
+ get
+ {
+ return false;
+ }
+ }
+ }
+}
diff --git a/MediaBrowser.ApiInteraction.Metro/MediaBrowser.ApiInteraction.Metro.csproj b/MediaBrowser.ApiInteraction.Metro/MediaBrowser.ApiInteraction.Metro.csproj new file mode 100644 index 0000000000..63a91ac498 --- /dev/null +++ b/MediaBrowser.ApiInteraction.Metro/MediaBrowser.ApiInteraction.Metro.csproj @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{94CEA07A-307C-4663-AA43-7BD852808574}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>MediaBrowser.ApiInteraction.Metro</RootNamespace>
+ <AssemblyName>MediaBrowser.ApiInteraction.Metro</AssemblyName>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <TargetFrameworkProfile>Profile7</TargetFrameworkProfile>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <!-- A reference to the entire .NET Framework is automatically included -->
+ <ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj">
+ <Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project>
+ <Name>MediaBrowser.Model</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="..\MediaBrowser.ApiInteraction\BaseApiClient.cs">
+ <Link>BaseApiClient.cs</Link>
+ </Compile>
+ <Compile Include="..\MediaBrowser.ApiInteraction\BaseHttpApiClient.cs">
+ <Link>BaseHttpApiClient.cs</Link>
+ </Compile>
+ <Compile Include="..\MediaBrowser.ApiInteraction\SerializationFormats.cs">
+ <Link>SerializationFormats.cs</Link>
+ </Compile>
+ <Compile Include="ApiClient.cs" />
+ <Compile Include="DataSerializer.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <Reference Include="Newtonsoft.Json">
+ <HintPath>..\Json.Net\Portable\Newtonsoft.Json.dll</HintPath>
+ </Reference>
+ <Reference Include="protobuf-net">
+ <HintPath>..\protobuf-net\Full\portable\protobuf-net.dll</HintPath>
+ </Reference>
+ <Reference Include="ProtobufModelSerializer">
+ <HintPath>..\MediaBrowser.Model\bin\ProtobufModelSerializer.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+ <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file diff --git a/MediaBrowser.ApiInteraction.Metro/Properties/AssemblyInfo.cs b/MediaBrowser.ApiInteraction.Metro/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..c9c876bc88 --- /dev/null +++ b/MediaBrowser.ApiInteraction.Metro/Properties/AssemblyInfo.cs @@ -0,0 +1,30 @@ +using System.Resources;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("MediaBrowser.ApiInteraction.Metro")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("MediaBrowser.ApiInteraction.Metro")]
+[assembly: AssemblyCopyright("Copyright © 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+[assembly: NeutralResourcesLanguage("en")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
|
