aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.ServerApplication/App.xaml.cs
diff options
context:
space:
mode:
authorLukePulverenti <luke.pulverenti@gmail.com>2013-02-23 02:57:11 -0500
committerLukePulverenti <luke.pulverenti@gmail.com>2013-02-23 02:57:11 -0500
commitb8d5c718429f1325111834b8b95698fc9c9ba47d (patch)
treef7f23b8704380552f25f3edfa3d706455069692e /MediaBrowser.ServerApplication/App.xaml.cs
parentc165f37bb96ad40d863a436795c21b9085f3fde9 (diff)
type discovery without attributes
Diffstat (limited to 'MediaBrowser.ServerApplication/App.xaml.cs')
-rw-r--r--MediaBrowser.ServerApplication/App.xaml.cs53
1 files changed, 39 insertions, 14 deletions
diff --git a/MediaBrowser.ServerApplication/App.xaml.cs b/MediaBrowser.ServerApplication/App.xaml.cs
index fd296e213..492fef242 100644
--- a/MediaBrowser.ServerApplication/App.xaml.cs
+++ b/MediaBrowser.ServerApplication/App.xaml.cs
@@ -11,6 +11,7 @@ using MediaBrowser.Model.Updates;
using MediaBrowser.Server.Uninstall;
using MediaBrowser.ServerApplication.Implementations;
using Microsoft.Win32;
+using SimpleInjector;
using System;
using System.Diagnostics;
using System.IO;
@@ -22,7 +23,6 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
-using SimpleInjector;
namespace MediaBrowser.ServerApplication
{
@@ -130,6 +130,12 @@ namespace MediaBrowser.ServerApplication
}
/// <summary>
+ /// Gets or sets the iso manager.
+ /// </summary>
+ /// <value>The iso manager.</value>
+ private IIsoManager IsoManager { get; set; }
+
+ /// <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>
@@ -182,18 +188,6 @@ namespace MediaBrowser.ServerApplication
}
/// <summary>
- /// Registers resources that classes will depend on
- /// </summary>
- private void RegisterResources()
- {
- Register(this);
- Register(Logger);
- Register<IIsoManager>(new PismoIsoManager(Logger));
- Register<IBlurayExaminer>(new BdInfoExaminer());
- Register<IZipClient>(new DotNetZipClient());
- }
-
- /// <summary>
/// Loads the kernel.
/// </summary>
protected async void LoadKernel()
@@ -510,6 +504,21 @@ namespace MediaBrowser.ServerApplication
}
/// <summary>
+ /// Registers resources that classes will depend on
+ /// </summary>
+ private void RegisterResources()
+ {
+ Register<IApplicationHost>(this);
+ Register(Logger);
+
+ IsoManager = new PismoIsoManager(Logger);
+
+ Register<IIsoManager>(IsoManager);
+ Register<IBlurayExaminer>(new BdInfoExaminer());
+ Register<IZipClient>(new DotNetZipClient());
+ }
+
+ /// <summary>
/// Creates an instance of type and resolves all constructor dependancies
/// </summary>
/// <param name="type">The type.</param>
@@ -544,9 +553,25 @@ namespace MediaBrowser.ServerApplication
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns>``0.</returns>
- public T Resolve<T>() where T : class
+ public T Resolve<T>()
{
return (T)_container.GetRegistration(typeof (T), true).GetInstance();
}
+
+ /// <summary>
+ /// Resolves this instance.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <returns>``0.</returns>
+ public T TryResolve<T>()
+ {
+ var result = _container.GetRegistration(typeof (T), false);
+
+ if (result == null)
+ {
+ return default(T);
+ }
+ return (T)result.GetInstance();
+ }
}
}