aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.ServerApplication/App.xaml.cs
diff options
context:
space:
mode:
authorLukePulverenti <luke.pulverenti@gmail.com>2013-03-04 00:43:06 -0500
committerLukePulverenti <luke.pulverenti@gmail.com>2013-03-04 00:43:06 -0500
commit2ca4b7d03adfa3cc7c9c6a597a11762142d5b34b (patch)
tree18a3d756bd6333a863ccb6d48161b97bb4c2d83a /MediaBrowser.ServerApplication/App.xaml.cs
parent401b56c732f7b22bce844770f75fcddbcc803092 (diff)
Created IConfigurationManager
Diffstat (limited to 'MediaBrowser.ServerApplication/App.xaml.cs')
-rw-r--r--MediaBrowser.ServerApplication/App.xaml.cs81
1 files changed, 9 insertions, 72 deletions
diff --git a/MediaBrowser.ServerApplication/App.xaml.cs b/MediaBrowser.ServerApplication/App.xaml.cs
index d79b2ff43..470b7fc55 100644
--- a/MediaBrowser.ServerApplication/App.xaml.cs
+++ b/MediaBrowser.ServerApplication/App.xaml.cs
@@ -1,4 +1,5 @@
using System.IO;
+using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Constants;
using MediaBrowser.Common.Kernel;
using MediaBrowser.Common.Updates;
@@ -72,12 +73,6 @@ namespace MediaBrowser.ServerApplication
private Mutex SingleInstanceMutex;
/// <summary>
- /// Gets or sets the kernel.
- /// </summary>
- /// <value>The kernel.</value>
- protected IKernel Kernel { get; set; }
-
- /// <summary>
/// Gets or sets the logger.
/// </summary>
/// <value>The logger.</value>
@@ -108,12 +103,6 @@ namespace MediaBrowser.ServerApplication
}
/// <summary>
- /// Gets or sets a value indicating whether [last run at startup value].
- /// </summary>
- /// <value><c>null</c> if [last run at startup value] contains no value, <c>true</c> if [last run at startup value]; otherwise, <c>false</c>.</value>
- private bool? LastRunAtStartupValue { get; set; }
-
- /// <summary>
/// Raises the <see cref="E:System.Windows.Application.Startup" /> event.
/// </summary>
/// <param name="e">A <see cref="T:System.Windows.StartupEventArgs" /> that contains the event data.</param>
@@ -164,26 +153,17 @@ namespace MediaBrowser.ServerApplication
/// </summary>
protected async void LoadKernel()
{
- CompositionRoot = new ApplicationHost();
- await CompositionRoot.Init();
-
- Logger = CompositionRoot.Logger;
- Kernel = CompositionRoot.Kernel;
-
try
{
- var win = (MainWindow)CompositionRoot.CreateInstance(typeof(MainWindow));
-
- win.Show();
+ CompositionRoot = new ApplicationHost();
- var now = DateTime.UtcNow;
+ var win = new MainWindow(CompositionRoot.LogManager, CompositionRoot, CompositionRoot.ServerConfigurationManager);
- Kernel.Init();
+ Logger = CompositionRoot.LogManager.GetLogger("App");
- var done = (DateTime.UtcNow - now);
- Logger.Info("Kernel.Init completed in {0}{1} minutes and {2} seconds.", done.Hours > 0 ? done.Hours + " Hours " : "", done.Minutes, done.Seconds);
+ win.Show();
- await OnKernelLoaded();
+ await CompositionRoot.Init();
}
catch (Exception ex)
{
@@ -197,41 +177,6 @@ namespace MediaBrowser.ServerApplication
}
/// <summary>
- /// Called when [kernel loaded].
- /// </summary>
- /// <returns>Task.</returns>
- protected Task OnKernelLoaded()
- {
- return Task.Run(() =>
- {
- Kernel.ConfigurationUpdated += Kernel_ConfigurationUpdated;
-
- ConfigureAutoRun();
- });
- }
-
- /// <summary>
- /// Handles the ConfigurationUpdated event of the Kernel control.
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
- void Kernel_ConfigurationUpdated(object sender, EventArgs e)
- {
- if (!LastRunAtStartupValue.HasValue || LastRunAtStartupValue.Value != Kernel.Configuration.RunAtStartup)
- {
- ConfigureAutoRun();
- }
- }
-
- /// <summary>
- /// Configures the click once startup.
- /// </summary>
- private void ConfigureAutoRun()
- {
- CompositionRoot.ConfigureAutoRunAtStartup(Kernel.Configuration.RunAtStartup);
- }
-
- /// <summary>
/// Raises the <see cref="E:System.Windows.Application.Exit" /> event.
/// </summary>
/// <param name="e">An <see cref="T:System.Windows.ExitEventArgs" /> that contains the event data.</param>
@@ -261,21 +206,13 @@ namespace MediaBrowser.ServerApplication
}
/// <summary>
- /// Opens the dashboard.
- /// </summary>
- public static void OpenDashboard(User loggedInUser)
- {
- OpenDashboardPage("dashboard.html", loggedInUser);
- }
-
- /// <summary>
/// Opens the dashboard page.
/// </summary>
/// <param name="page">The page.</param>
- public static void OpenDashboardPage(string page, User loggedInUser)
+ public static void OpenDashboardPage(string page, User loggedInUser, IConfigurationManager configurationManager)
{
- var url = "http://localhost:" + Controller.Kernel.Instance.Configuration.HttpServerPortNumber + "/" +
- Controller.Kernel.Instance.WebApplicationName + "/dashboard/" + page;
+ var url = "http://localhost:" + configurationManager.CommonConfiguration.HttpServerPortNumber + "/" +
+ Kernel.Instance.WebApplicationName + "/dashboard/" + page;
if (loggedInUser != null)
{