From 8ce3e74e8112a94773df22827849bf274fc88198 Mon Sep 17 00:00:00 2001 From: LukePulverenti Date: Sun, 24 Feb 2013 16:53:54 -0500 Subject: More DI --- MediaBrowser.Common/Kernel/BaseApplicationPaths.cs | 304 --------------------- 1 file changed, 304 deletions(-) delete mode 100644 MediaBrowser.Common/Kernel/BaseApplicationPaths.cs (limited to 'MediaBrowser.Common/Kernel/BaseApplicationPaths.cs') diff --git a/MediaBrowser.Common/Kernel/BaseApplicationPaths.cs b/MediaBrowser.Common/Kernel/BaseApplicationPaths.cs deleted file mode 100644 index 936c484c8..000000000 --- a/MediaBrowser.Common/Kernel/BaseApplicationPaths.cs +++ /dev/null @@ -1,304 +0,0 @@ -using System; -using System.Configuration; -using System.IO; -using System.Reflection; - -namespace MediaBrowser.Common.Kernel -{ - /// - /// Provides a base class to hold common application paths used by both the Ui and Server. - /// This can be subclassed to add application-specific paths. - /// - public abstract class BaseApplicationPaths - { - /// - /// The _program data path - /// - private string _programDataPath; - /// - /// Gets the path to the program data folder - /// - /// The program data path. - public string ProgramDataPath - { - get - { - return _programDataPath ?? (_programDataPath = GetProgramDataPath()); - } - } - - /// - /// The _data directory - /// - private string _dataDirectory; - /// - /// Gets the folder path to the data directory - /// - /// The data directory. - public string DataPath - { - get - { - if (_dataDirectory == null) - { - _dataDirectory = Path.Combine(ProgramDataPath, "data"); - - if (!Directory.Exists(_dataDirectory)) - { - Directory.CreateDirectory(_dataDirectory); - } - } - - return _dataDirectory; - } - } - - /// - /// The _image cache path - /// - private string _imageCachePath; - /// - /// Gets the image cache path. - /// - /// The image cache path. - public string ImageCachePath - { - get - { - if (_imageCachePath == null) - { - _imageCachePath = Path.Combine(CachePath, "images"); - - if (!Directory.Exists(_imageCachePath)) - { - Directory.CreateDirectory(_imageCachePath); - } - } - - return _imageCachePath; - } - } - - /// - /// The _plugins path - /// - private string _pluginsPath; - /// - /// Gets the path to the plugin directory - /// - /// The plugins path. - public string PluginsPath - { - get - { - if (_pluginsPath == null) - { - _pluginsPath = Path.Combine(ProgramDataPath, "plugins"); - if (!Directory.Exists(_pluginsPath)) - { - Directory.CreateDirectory(_pluginsPath); - } - } - - return _pluginsPath; - } - } - - /// - /// The _plugin configurations path - /// - private string _pluginConfigurationsPath; - /// - /// Gets the path to the plugin configurations directory - /// - /// The plugin configurations path. - public string PluginConfigurationsPath - { - get - { - if (_pluginConfigurationsPath == null) - { - _pluginConfigurationsPath = Path.Combine(PluginsPath, "configurations"); - if (!Directory.Exists(_pluginConfigurationsPath)) - { - Directory.CreateDirectory(_pluginConfigurationsPath); - } - } - - return _pluginConfigurationsPath; - } - } - - private string _tempUpdatePath; - /// - /// Gets the path to where temporary update files will be stored - /// - /// The plugin configurations path. - public string TempUpdatePath - { - get - { - if (_tempUpdatePath == null) - { - _tempUpdatePath = Path.Combine(ProgramDataPath, "Updates"); - if (!Directory.Exists(_tempUpdatePath)) - { - Directory.CreateDirectory(_tempUpdatePath); - } - } - - return _tempUpdatePath; - } - } - - /// - /// The _log directory path - /// - private string _logDirectoryPath; - /// - /// Gets the path to the log directory - /// - /// The log directory path. - public string LogDirectoryPath - { - get - { - if (_logDirectoryPath == null) - { - _logDirectoryPath = Path.Combine(ProgramDataPath, "logs"); - if (!Directory.Exists(_logDirectoryPath)) - { - Directory.CreateDirectory(_logDirectoryPath); - } - } - return _logDirectoryPath; - } - } - - /// - /// The _configuration directory path - /// - private string _configurationDirectoryPath; - /// - /// Gets the path to the application configuration root directory - /// - /// The configuration directory path. - public string ConfigurationDirectoryPath - { - get - { - if (_configurationDirectoryPath == null) - { - _configurationDirectoryPath = Path.Combine(ProgramDataPath, "config"); - if (!Directory.Exists(_configurationDirectoryPath)) - { - Directory.CreateDirectory(_configurationDirectoryPath); - } - } - return _configurationDirectoryPath; - } - } - - /// - /// The _system configuration file path - /// - private string _systemConfigurationFilePath; - /// - /// Gets the path to the system configuration file - /// - /// The system configuration file path. - public string SystemConfigurationFilePath - { - get - { - return _systemConfigurationFilePath ?? (_systemConfigurationFilePath = Path.Combine(ConfigurationDirectoryPath, "system.xml")); - } - } - - /// - /// The _cache directory - /// - private string _cachePath; - /// - /// Gets the folder path to the cache directory - /// - /// The cache directory. - public string CachePath - { - get - { - if (_cachePath == null) - { - _cachePath = Path.Combine(ProgramDataPath, "cache"); - - if (!Directory.Exists(_cachePath)) - { - Directory.CreateDirectory(_cachePath); - } - } - - return _cachePath; - } - } - - /// - /// The _temp directory - /// - private string _tempDirectory; - /// - /// Gets the folder path to the temp directory within the cache folder - /// - /// The temp directory. - public string TempDirectory - { - get - { - if (_tempDirectory == null) - { - _tempDirectory = Path.Combine(CachePath, "temp"); - - if (!Directory.Exists(_tempDirectory)) - { - Directory.CreateDirectory(_tempDirectory); - } - } - - return _tempDirectory; - } - } - - /// - /// Gets the path to the application's ProgramDataFolder - /// - /// System.String. - public static string GetProgramDataPath() - { -#if DEBUG - string programDataPath = ConfigurationManager.AppSettings["DebugProgramDataPath"]; - -#else - string programDataPath = Path.Combine(ConfigurationManager.AppSettings["ReleaseProgramDataPath"], ConfigurationManager.AppSettings["ProgramDataFolderName"]); -#endif - - programDataPath = programDataPath.Replace("%CommonApplicationData%", Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)); - - // If it's a relative path, e.g. "..\" - if (!Path.IsPathRooted(programDataPath)) - { - var path = Assembly.GetExecutingAssembly().Location; - path = Path.GetDirectoryName(path); - - programDataPath = Path.Combine(path, programDataPath); - - programDataPath = Path.GetFullPath(programDataPath); - } - - if (!Directory.Exists(programDataPath)) - { - Directory.CreateDirectory(programDataPath); - } - - return programDataPath; - } - } -} -- cgit v1.2.3