mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 05:23:31 -07:00
fixed service registration for event handlers and executors.
This commit is contained in:
parent
399c96c5e3
commit
fa8f67d7fe
12 changed files with 190 additions and 95 deletions
39
NzbDrone.Common/ServiceFactory.cs
Normal file
39
NzbDrone.Common/ServiceFactory.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using TinyIoC;
|
||||
|
||||
namespace NzbDrone.Common
|
||||
{
|
||||
public interface IServiceFactory
|
||||
{
|
||||
T Build<T>() where T : class;
|
||||
IEnumerable<T> BuildAll<T>() where T : class;
|
||||
object Build(Type contract);
|
||||
}
|
||||
|
||||
public class ServiceFactory : IServiceFactory
|
||||
{
|
||||
private readonly TinyIoCContainer _container;
|
||||
|
||||
public ServiceFactory(TinyIoCContainer container)
|
||||
{
|
||||
_container = container;
|
||||
}
|
||||
|
||||
public T Build<T>() where T : class
|
||||
{
|
||||
return _container.Resolve<T>();
|
||||
}
|
||||
|
||||
public IEnumerable<T> BuildAll<T>() where T : class
|
||||
{
|
||||
return _container.ResolveAll<T>();
|
||||
}
|
||||
|
||||
public object Build(Type contract)
|
||||
{
|
||||
return _container.Resolve(contract);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue