From 7b0b5a35382d0b43f298d7ef015d6fd3031a8c72 Mon Sep 17 00:00:00 2001 From: LukePulverenti Date: Sun, 3 Mar 2013 02:27:40 -0500 Subject: [PATCH] created an init method on base app host --- .../BaseApplicationHost.cs | 31 +++++++++++++------ .../Kernel/IApplicationHost.cs | 6 ++++ MediaBrowser.ServerApplication/App.xaml.cs | 1 + .../ApplicationHost.cs | 10 ++++++ Nuget/MediaBrowser.Common.Internal.nuspec | 4 +-- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +-- 7 files changed, 43 insertions(+), 15 deletions(-) diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs index 3d7421f67f..4e1b4634ec 100644 --- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs +++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.Implementations.Udp; +using System.Threading.Tasks; +using MediaBrowser.Common.Implementations.Udp; using MediaBrowser.Common.Implementations.Updates; using MediaBrowser.Common.Implementations.WebSocket; using MediaBrowser.Common.Kernel; @@ -48,7 +49,7 @@ namespace MediaBrowser.Common.Implementations /// The container /// protected readonly Container Container = new Container(); - + /// /// Gets assemblies that failed to load /// @@ -114,16 +115,26 @@ namespace MediaBrowser.Common.Implementations protected BaseApplicationHost() { FailedAssemblies = new List(); + } - ApplicationPaths = GetApplicationPaths(); + /// + /// Inits this instance. + /// + /// Task. + public virtual Task Init() + { + return Task.Run(() => + { + ApplicationPaths = GetApplicationPaths(); - LogManager = GetLogManager(); + LogManager = GetLogManager(); - Logger = LogManager.GetLogger("App"); + Logger = LogManager.GetLogger("App"); - IsFirstRun = !File.Exists(ApplicationPaths.SystemConfigurationFilePath); + IsFirstRun = !File.Exists(ApplicationPaths.SystemConfigurationFilePath); - DiscoverTypes(); + DiscoverTypes(); + }); } /// @@ -157,7 +168,7 @@ namespace MediaBrowser.Common.Implementations Plugins = GetExports(); } - + /// /// Discovers the types. /// @@ -189,7 +200,7 @@ namespace MediaBrowser.Common.Implementations RegisterSingleInstance(networkManager); RegisterSingleInstance(serverManager); } - + /// /// Gets a list of types within an assembly /// This will handle situations that would normally throw an exception - such as a type within the assembly that depends on some other non-existant reference @@ -353,7 +364,7 @@ namespace MediaBrowser.Common.Implementations /// if set to true [autorun]. public void ConfigureAutoRunAtStartup(bool autorun) { - + } /// diff --git a/MediaBrowser.Common/Kernel/IApplicationHost.cs b/MediaBrowser.Common/Kernel/IApplicationHost.cs index 29934988a2..38a1cb3180 100644 --- a/MediaBrowser.Common/Kernel/IApplicationHost.cs +++ b/MediaBrowser.Common/Kernel/IApplicationHost.cs @@ -110,5 +110,11 @@ namespace MediaBrowser.Common.Kernel /// /// The plugin. void RemovePlugin(IPlugin plugin); + + /// + /// Inits this instance. + /// + /// Task. + Task Init(); } } diff --git a/MediaBrowser.ServerApplication/App.xaml.cs b/MediaBrowser.ServerApplication/App.xaml.cs index 95ece67e6c..d79b2ff437 100644 --- a/MediaBrowser.ServerApplication/App.xaml.cs +++ b/MediaBrowser.ServerApplication/App.xaml.cs @@ -165,6 +165,7 @@ namespace MediaBrowser.ServerApplication protected async void LoadKernel() { CompositionRoot = new ApplicationHost(); + await CompositionRoot.Init(); Logger = CompositionRoot.Logger; Kernel = CompositionRoot.Kernel; diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index d70d179a6b..668887a56f 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -78,6 +78,16 @@ namespace MediaBrowser.ServerApplication public ApplicationHost() : base() { + } + + /// + /// Inits this instance. + /// + /// Task. + public override async Task Init() + { + await base.Init().ConfigureAwait(false); + Kernel = new Kernel(this, ServerApplicationPaths, _xmlSerializer, Logger); var networkManager = new NetworkManager(); diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 748191c031..b51ed3cc02 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.24 + 3.0.25 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theatre and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index e1bb8b3e60..19b37c869d 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.24 + 3.0.25 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 04f326348e..dfcb28aa0d 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.24 + 3.0.25 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - +