mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 13:33:34 -07:00
all services are singleton by default.
This commit is contained in:
parent
8bdf8c31f0
commit
763df726f0
12 changed files with 5 additions and 34 deletions
|
@ -86,9 +86,9 @@ namespace NzbDrone.Common.Composition
|
|||
_container.Register(registrationType, instance);
|
||||
}
|
||||
|
||||
public void RegisterAll(Type registrationType, IEnumerable<Type> implementationList)
|
||||
public void RegisterAllAsSingleton(Type registrationType, IEnumerable<Type> implementationList)
|
||||
{
|
||||
_container.RegisterMultiple(registrationType, implementationList);
|
||||
_container.RegisterMultiple(registrationType, implementationList).AsSingleton();
|
||||
}
|
||||
|
||||
public bool IsTypeRegistered(Type type)
|
||||
|
|
|
@ -64,22 +64,12 @@ namespace NzbDrone.Common.Composition
|
|||
var impl = implementations.Single();
|
||||
|
||||
Trace.WriteLine(string.Format("Registering {0} -> {1}", contractType.FullName, impl.Name));
|
||||
|
||||
|
||||
if (impl.HasAttribute<SingletonAttribute>())
|
||||
{
|
||||
Container.RegisterSingleton(contractType, impl);
|
||||
}
|
||||
else
|
||||
{
|
||||
Container.Register(contractType, impl);
|
||||
}
|
||||
Container.RegisterSingleton(contractType, impl);
|
||||
}
|
||||
else
|
||||
{
|
||||
Trace.WriteLine(string.Format("Registering {0} -> {1}", contractType.FullName, implementations.Count));
|
||||
|
||||
Container.RegisterAll(contractType, implementations);
|
||||
Container.RegisterAllAsSingleton(contractType, implementations);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace NzbDrone.Common.Composition
|
|||
IEnumerable<T> ResolveAll<T>() where T : class;
|
||||
IEnumerable<object> ResolveAll(Type type);
|
||||
void Register(Type registrationType, object instance);
|
||||
void RegisterAll(Type registrationType, IEnumerable<Type> implementationList);
|
||||
void RegisterAllAsSingleton(Type registrationType, IEnumerable<Type> implementationList);
|
||||
bool IsTypeRegistered(Type type);
|
||||
|
||||
IEnumerable<Type> GetImplementations(Type contractType);
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace NzbDrone.Common.Composition
|
||||
{
|
||||
public class SingletonAttribute : Attribute
|
||||
{
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue