Added protobuf support for serializing ServerConfiguration

This commit is contained in:
LukePulverenti Luke Pulverenti luke pulverenti 2012-09-08 16:25:56 -04:00
parent 8b39ed2f63
commit 50f88997ba
4 changed files with 22 additions and 10 deletions

View file

@ -269,10 +269,7 @@ namespace MediaBrowser.ApiInteraction.Portable
{
string url = ApiUrl + "/ServerConfiguration";
// At the moment this can't be retrieved in protobuf format
SerializationFormats format = DataSerializer.CanDeSerializeJsv ? SerializationFormats.Jsv : SerializationFormats.Json;
GetDataAsync(url, callback, format);
GetDataAsync(url, callback);
}
/// <summary>

View file

@ -313,12 +313,9 @@ namespace MediaBrowser.ApiInteraction
{
string url = ApiUrl + "/ServerConfiguration";
// At the moment this can't be retrieved in protobuf format
SerializationFormats format = DataSerializer.CanDeSerializeJsv ? SerializationFormats.Jsv : SerializationFormats.Json;
using (Stream stream = await GetSerializedStreamAsync(url, format).ConfigureAwait(false))
using (Stream stream = await GetSerializedStreamAsync(url).ConfigureAwait(false))
{
return DataSerializer.DeserializeFromStream<ServerConfiguration>(stream, format);
return DeserializeFromStream<ServerConfiguration>(stream);
}
}

View file

@ -1,12 +1,19 @@

using ProtoBuf;
namespace MediaBrowser.Model.Configuration
{
/// <summary>
/// Serves as a common base class for the Server and UI application Configurations
/// ProtoInclude tells Protobuf about subclasses,
/// The number 50 can be any number, so long as it doesn't clash with any of the ProtoMember numbers either here or in subclasses.
/// </summary>
[ProtoContract, ProtoInclude(50, typeof(ServerConfiguration))]
public class BaseApplicationConfiguration
{
[ProtoMember(1)]
public bool EnableDebugLevelLogging { get; set; }
[ProtoMember(2)]
public int HttpServerPortNumber { get; set; }
public BaseApplicationConfiguration()

View file

@ -1,13 +1,24 @@
using MediaBrowser.Model.Weather;
using ProtoBuf;
namespace MediaBrowser.Model.Configuration
{
/// <summary>
/// Represents the server configuration.
/// </summary>
[ProtoContract]
public class ServerConfiguration : BaseApplicationConfiguration
{
[ProtoMember(3)]
public bool EnableInternetProviders { get; set; }
[ProtoMember(4)]
public bool EnableUserProfiles { get; set; }
[ProtoMember(5)]
public string WeatherZipCode { get; set; }
[ProtoMember(6)]
public WeatherUnits WeatherUnit { get; set; }
public ServerConfiguration()