mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-23 22:25:09 -04:00
@@ -1,14 +1,16 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Common.Composition;
|
||||
|
||||
namespace NzbDrone.Common
|
||||
{
|
||||
public interface IServiceFactory
|
||||
{
|
||||
T Build<T>() where T : class;
|
||||
IEnumerable<T> BuildAll<T>() where T : class;
|
||||
T Build<T>()
|
||||
where T : class;
|
||||
IEnumerable<T> BuildAll<T>()
|
||||
where T : class;
|
||||
object Build(Type contract);
|
||||
IEnumerable<Type> GetImplementations(Type contract);
|
||||
}
|
||||
@@ -22,12 +24,14 @@ namespace NzbDrone.Common
|
||||
_container = container;
|
||||
}
|
||||
|
||||
public T Build<T>() where T : class
|
||||
public T Build<T>()
|
||||
where T : class
|
||||
{
|
||||
return _container.Resolve<T>();
|
||||
}
|
||||
|
||||
public IEnumerable<T> BuildAll<T>() where T : class
|
||||
public IEnumerable<T> BuildAll<T>()
|
||||
where T : class
|
||||
{
|
||||
return _container.ResolveAll<T>().GroupBy(c => c.GetType().FullName).Select(g => g.First());
|
||||
}
|
||||
@@ -42,4 +46,4 @@ namespace NzbDrone.Common
|
||||
return _container.GetImplementations(contract);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user