mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-23 17:24:46 +03:00
type discovery without attributes
This commit is contained in:
@@ -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
|
||||
{
|
||||
@@ -129,6 +129,12 @@ namespace MediaBrowser.ServerApplication
|
||||
get { return "MediaBrowser.Server.Uninstall.exe"; }
|
||||
}
|
||||
|
||||
/// <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>
|
||||
@@ -181,18 +187,6 @@ namespace MediaBrowser.ServerApplication
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
/// <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>
|
||||
@@ -509,6 +503,21 @@ namespace MediaBrowser.ServerApplication
|
||||
return new ApplicationUpdater().UpdateApplication(cancellationToken, progress);
|
||||
}
|
||||
|
||||
/// <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>
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user