1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-28 18:47:52 +00:00
Lidarr/NzbDrone.Common/ServiceFactory.cs

39 lines
No EOL
875 B
C#

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);
}
}
}