From 4e79eaf65e8edb895f9337a8b878ff9ef312b3f6 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 4 Dec 2013 09:52:38 -0500 Subject: add ApplicationPath to app paths interface to hide implementation --- .../BaseApplicationHost.cs | 15 +++++++++++---- .../BaseApplicationPaths.cs | 10 ++++++---- .../Serialization/JsonSerializer.cs | 4 ++-- 3 files changed, 19 insertions(+), 10 deletions(-) (limited to 'MediaBrowser.Common.Implementations') diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs index becf649f4..e8f4d51eb 100644 --- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs +++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs @@ -33,7 +33,7 @@ namespace MediaBrowser.Common.Implementations /// /// The type of the T application paths type. public abstract class BaseApplicationHost : IApplicationHost - where TApplicationPathsType : class, IApplicationPaths, new() + where TApplicationPathsType : class, IApplicationPaths { /// /// Occurs when [has pending restart changed]. @@ -83,7 +83,7 @@ namespace MediaBrowser.Common.Implementations /// /// The json serializer /// - public readonly IJsonSerializer JsonSerializer = new JsonSerializer(); + public IJsonSerializer JsonSerializer { get; private set; } /// /// The _XML serializer @@ -153,7 +153,7 @@ namespace MediaBrowser.Common.Implementations protected IInstallationManager InstallationManager { get; private set; } protected IFileSystem FileSystemManager { get; private set; } - + /// /// Gets or sets the zip client. /// @@ -181,6 +181,8 @@ namespace MediaBrowser.Common.Implementations /// Task. public virtual async Task Init() { + JsonSerializer = CreateJsonSerializer(); + IsFirstRun = !ConfigurationManager.CommonConfiguration.IsStartupWizardCompleted; Logger = LogManager.GetLogger("App"); @@ -212,6 +214,11 @@ namespace MediaBrowser.Common.Implementations } + protected virtual IJsonSerializer CreateJsonSerializer() + { + return new JsonSerializer(); + } + private void SetHttpLimit() { try @@ -224,7 +231,7 @@ namespace MediaBrowser.Common.Implementations Logger.ErrorException("Error setting http limit", ex); } } - + /// /// Installs the iso mounters. /// diff --git a/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs b/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs index bee5e5dc4..ba68d1f5a 100644 --- a/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs +++ b/MediaBrowser.Common.Implementations/BaseApplicationPaths.cs @@ -20,21 +20,23 @@ namespace MediaBrowser.Common.Implementations /// /// Initializes a new instance of the class. /// - /// if set to true [use debug paths]. - protected BaseApplicationPaths(bool useDebugPath) + protected BaseApplicationPaths(bool useDebugPath, string applicationPath) { _useDebugPath = useDebugPath; + ApplicationPath = applicationPath; } /// /// Initializes a new instance of the class. /// - /// The program data path. - protected BaseApplicationPaths(string programDataPath) + protected BaseApplicationPaths(string programDataPath, string applicationPath) { _programDataPath = programDataPath; + ApplicationPath = applicationPath; } + public string ApplicationPath { get; private set; } + /// /// The _program data path /// diff --git a/MediaBrowser.Common.Implementations/Serialization/JsonSerializer.cs b/MediaBrowser.Common.Implementations/Serialization/JsonSerializer.cs index 3ff956040..9c2412b22 100644 --- a/MediaBrowser.Common.Implementations/Serialization/JsonSerializer.cs +++ b/MediaBrowser.Common.Implementations/Serialization/JsonSerializer.cs @@ -80,7 +80,7 @@ namespace MediaBrowser.Common.Implementations.Serialization using (Stream stream = File.OpenRead(file)) { - return ServiceStack.Text.JsonSerializer.DeserializeFromStream(type, stream); + return DeserializeFromStream(stream, type); } } @@ -101,7 +101,7 @@ namespace MediaBrowser.Common.Implementations.Serialization using (Stream stream = File.OpenRead(file)) { - return ServiceStack.Text.JsonSerializer.DeserializeFromStream(stream); + return DeserializeFromStream(stream); } } -- cgit v1.2.3