aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2016-10-23 19:49:13 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2016-10-23 19:49:13 -0400
commit2af3ec43d52d44ff7b456de35e45b12413edcf9d (patch)
tree0870f82ea5a2636f84635201433deab8b89143f4 /MediaBrowser.Common.Implementations/BaseApplicationHost.cs
parentabc5a2eabd005c0032687ea051c4285f32258635 (diff)
make common project portable
Diffstat (limited to 'MediaBrowser.Common.Implementations/BaseApplicationHost.cs')
-rw-r--r--MediaBrowser.Common.Implementations/BaseApplicationHost.cs64
1 files changed, 34 insertions, 30 deletions
diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
index baf6d85af..1f7c45626 100644
--- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
+++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
@@ -205,14 +205,14 @@ namespace MediaBrowser.Common.Implementations
/// <summary>
/// Initializes a new instance of the <see cref="BaseApplicationHost{TApplicationPathsType}"/> class.
/// </summary>
- protected BaseApplicationHost(TApplicationPathsType applicationPaths,
- ILogManager logManager,
+ protected BaseApplicationHost(TApplicationPathsType applicationPaths,
+ ILogManager logManager,
IFileSystem fileSystem)
{
// hack alert, until common can target .net core
BaseExtensions.CryptographyProvider = CryptographyProvider;
- XmlSerializer = new XmlSerializer (fileSystem, logManager.GetLogger("XmlSerializer"));
+ XmlSerializer = new XmlSerializer(fileSystem, logManager.GetLogger("XmlSerializer"));
FailedAssemblies = new List<string>();
ApplicationPaths = applicationPaths;
@@ -396,13 +396,13 @@ namespace MediaBrowser.Common.Implementations
/// <returns>Task.</returns>
public virtual Task RunStartupTasks()
{
- Resolve<ITaskManager>().AddTasks(GetExports<IScheduledTask>(false));
+ Resolve<ITaskManager>().AddTasks(GetExports<IScheduledTask>(false));
- ConfigureAutorun ();
+ ConfigureAutorun();
- ConfigurationManager.ConfigurationUpdated += OnConfigurationUpdated;
+ ConfigurationManager.ConfigurationUpdated += OnConfigurationUpdated;
- return Task.FromResult (true);
+ return Task.FromResult(true);
}
/// <summary>
@@ -438,7 +438,7 @@ namespace MediaBrowser.Common.Implementations
protected virtual void FindParts()
{
RegisterModules();
-
+
ConfigurationManager.AddParts(GetExports<IConfigurationFactory>());
Plugins = GetExports<IPlugin>().Select(LoadPlugin).Where(i => i != null).ToArray();
}
@@ -462,6 +462,10 @@ namespace MediaBrowser.Common.Implementations
assemblyPlugin.SetAttributes(assemblyFilePath, assemblyFileName, assemblyName.Version, assemblyId);
}
+
+ var isFirstRun = !File.Exists(plugin.ConfigurationFilePath);
+
+ plugin.SetStartupInfo(isFirstRun, File.GetLastWriteTimeUtc, s => Directory.CreateDirectory(s));
}
catch (Exception ex)
{
@@ -498,43 +502,43 @@ namespace MediaBrowser.Common.Implementations
/// <returns>Task.</returns>
protected virtual Task RegisterResources(IProgress<double> progress)
{
- RegisterSingleInstance(ConfigurationManager);
- RegisterSingleInstance<IApplicationHost>(this);
+ RegisterSingleInstance(ConfigurationManager);
+ RegisterSingleInstance<IApplicationHost>(this);
- RegisterSingleInstance<IApplicationPaths>(ApplicationPaths);
+ RegisterSingleInstance<IApplicationPaths>(ApplicationPaths);
- TaskManager = new TaskManager(ApplicationPaths, JsonSerializer, LogManager.GetLogger("TaskManager"), FileSystemManager);
+ TaskManager = new TaskManager(ApplicationPaths, JsonSerializer, LogManager.GetLogger("TaskManager"), FileSystemManager);
- RegisterSingleInstance(JsonSerializer);
- RegisterSingleInstance(XmlSerializer);
+ RegisterSingleInstance(JsonSerializer);
+ RegisterSingleInstance(XmlSerializer);
RegisterSingleInstance(MemoryStreamProvider);
- RegisterSingleInstance(LogManager);
- RegisterSingleInstance(Logger);
+ RegisterSingleInstance(LogManager);
+ RegisterSingleInstance(Logger);
- RegisterSingleInstance(TaskManager);
+ RegisterSingleInstance(TaskManager);
- RegisterSingleInstance(FileSystemManager);
+ RegisterSingleInstance(FileSystemManager);
HttpClient = new HttpClientManager.HttpClientManager(ApplicationPaths, LogManager.GetLogger("HttpClient"), FileSystemManager, MemoryStreamProvider);
- RegisterSingleInstance(HttpClient);
+ RegisterSingleInstance(HttpClient);
- NetworkManager = CreateNetworkManager(LogManager.GetLogger("NetworkManager"));
- RegisterSingleInstance(NetworkManager);
+ NetworkManager = CreateNetworkManager(LogManager.GetLogger("NetworkManager"));
+ RegisterSingleInstance(NetworkManager);
- SecurityManager = new PluginSecurityManager(this, HttpClient, JsonSerializer, ApplicationPaths, LogManager);
- RegisterSingleInstance(SecurityManager);
+ SecurityManager = new PluginSecurityManager(this, HttpClient, JsonSerializer, ApplicationPaths, LogManager);
+ RegisterSingleInstance(SecurityManager);
InstallationManager = new InstallationManager(LogManager.GetLogger("InstallationManager"), this, ApplicationPaths, HttpClient, JsonSerializer, SecurityManager, ConfigurationManager, FileSystemManager);
- RegisterSingleInstance(InstallationManager);
+ RegisterSingleInstance(InstallationManager);
- ZipClient = new ZipClient(FileSystemManager);
- RegisterSingleInstance(ZipClient);
+ ZipClient = new ZipClient(FileSystemManager);
+ RegisterSingleInstance(ZipClient);
- IsoManager = new IsoManager();
- RegisterSingleInstance(IsoManager);
+ IsoManager = new IsoManager();
+ RegisterSingleInstance(IsoManager);
- return Task.FromResult (true);
+ return Task.FromResult(true);
}
private void RegisterModules()
@@ -583,7 +587,7 @@ namespace MediaBrowser.Common.Implementations
Logger.Error("LoaderException: " + loaderException.Message);
}
}
-
+
// If it fails we can still get a list of the Types it was able to resolve
return ex.Types.Where(t => t != null);
}