From 2ca4b7d03adfa3cc7c9c6a597a11762142d5b34b Mon Sep 17 00:00:00 2001 From: LukePulverenti Date: Mon, 4 Mar 2013 00:43:06 -0500 Subject: Created IConfigurationManager --- MediaBrowser.Controller/Entities/BaseItem.cs | 13 ++++++++----- MediaBrowser.Controller/Entities/User.cs | 14 ++++++++------ 2 files changed, 16 insertions(+), 11 deletions(-) (limited to 'MediaBrowser.Controller/Entities') diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 47c129dea3..e80c3d71f3 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -1,4 +1,6 @@ -using MediaBrowser.Common.Extensions; +using MediaBrowser.Common.Configuration; +using MediaBrowser.Common.Extensions; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.IO; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Localization; @@ -96,6 +98,7 @@ namespace MediaBrowser.Controller.Entities /// protected static internal ILogger Logger { get; internal set; } protected static internal ILibraryManager LibraryManager { get; internal set; } + protected static internal IServerConfigurationManager ConfigurationManager { get; internal set; } /// /// Returns a that represents this instance. @@ -311,7 +314,7 @@ namespace MediaBrowser.Controller.Entities // non file-system entries will not have a path if (string.IsNullOrEmpty(path)) { - return new ItemResolveArgs + return new ItemResolveArgs(ConfigurationManager.ApplicationPaths) { FileInfo = new WIN32_FIND_DATA() }; @@ -329,7 +332,7 @@ namespace MediaBrowser.Controller.Entities throw new IOException("Unable to retrieve file system info for " + path); } - var args = new ItemResolveArgs + var args = new ItemResolveArgs(ConfigurationManager.ApplicationPaths) { FileInfo = pathInfo.Value, Path = path, @@ -997,7 +1000,7 @@ namespace MediaBrowser.Controller.Entities throw new ArgumentNullException(); } - return (DateTime.UtcNow - DateCreated).TotalDays < Kernel.Instance.Configuration.RecentItemDays; + return (DateTime.UtcNow - DateCreated).TotalDays < ConfigurationManager.Configuration.RecentItemDays; } /// @@ -1020,7 +1023,7 @@ namespace MediaBrowser.Controller.Entities return false; } - return (DateTime.UtcNow - data.LastPlayedDate.Value).TotalDays < Kernel.Instance.Configuration.RecentlyPlayedDays; + return (DateTime.UtcNow - data.LastPlayedDate.Value).TotalDays < ConfigurationManager.Configuration.RecentlyPlayedDays; } /// diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs index bf77cdc959..ef50a08671 100644 --- a/MediaBrowser.Controller/Entities/User.cs +++ b/MediaBrowser.Controller/Entities/User.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.Extensions; +using MediaBrowser.Common.Configuration; +using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.IO; using MediaBrowser.Controller.Library; using MediaBrowser.Model.Configuration; @@ -18,6 +19,7 @@ namespace MediaBrowser.Controller.Entities public class User : BaseItem { internal static IUserManager UserManager { get; set; } + internal static IXmlSerializer XmlSerializer { get; set; } /// /// The _root folder path @@ -45,7 +47,7 @@ namespace MediaBrowser.Controller.Entities } else { - _rootFolderPath = Kernel.Instance.ApplicationPaths.DefaultUserViewsPath; + _rootFolderPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath; } } return _rootFolderPath; @@ -61,7 +63,7 @@ namespace MediaBrowser.Controller.Entities { var safeFolderName = FileSystem.GetValidFilename(username); - return System.IO.Path.Combine(Kernel.Instance.ApplicationPaths.RootFolderPath, safeFolderName); + return System.IO.Path.Combine(ConfigurationManager.ApplicationPaths.RootFolderPath, safeFolderName); } /// @@ -171,7 +173,7 @@ namespace MediaBrowser.Controller.Entities get { // Lazy load - LazyInitializer.EnsureInitialized(ref _configuration, ref _configurationInitialized, ref _configurationSyncLock, () => (UserConfiguration)Kernel.Instance.GetXmlConfiguration(typeof(UserConfiguration), ConfigurationFilePath)); + LazyInitializer.EnsureInitialized(ref _configuration, ref _configurationInitialized, ref _configurationSyncLock, () => (UserConfiguration)ConfigurationHelper.GetXmlConfiguration(typeof(UserConfiguration), ConfigurationFilePath, XmlSerializer)); return _configuration; } private set @@ -321,7 +323,7 @@ namespace MediaBrowser.Controller.Entities { var safeFolderName = FileSystem.GetValidFilename(username); - return System.IO.Path.Combine(Kernel.Instance.ApplicationPaths.UserConfigurationDirectoryPath, safeFolderName); + return System.IO.Path.Combine(ConfigurationManager.ApplicationPaths.UserConfigurationDirectoryPath, safeFolderName); } /// @@ -411,7 +413,7 @@ namespace MediaBrowser.Controller.Entities { var userPath = RootFolderPath; - var defaultPath = Kernel.Instance.ApplicationPaths.DefaultUserViewsPath; + var defaultPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath; if (userPath.Equals(defaultPath, StringComparison.OrdinalIgnoreCase)) { -- cgit v1.2.3