all services are singleton by default.
This commit is contained in:
parent
8bdf8c31f0
commit
763df726f0
|
@ -19,7 +19,6 @@ using TinyIoC;
|
|||
|
||||
namespace NzbDrone.Api
|
||||
{
|
||||
[Singleton]
|
||||
public class NancyBootstrapper : TinyIoCNancyBootstrapper
|
||||
{
|
||||
private readonly TinyIoCContainer _tinyIoCContainer;
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.AspNet.SignalR.Json;
|
||||
using NzbDrone.Common.Composition;
|
||||
using NzbDrone.Common.Serializer;
|
||||
|
||||
namespace NzbDrone.Api.SignalR
|
||||
{
|
||||
[Singleton]
|
||||
public class Serializer : IJsonSerializer
|
||||
{
|
||||
private readonly JsonNetSerializer _signalRSerializer = new JsonNetSerializer();
|
||||
|
|
|
@ -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
|
||||
{
|
||||
}
|
||||
}
|
|
@ -3,13 +3,11 @@ using System.Linq;
|
|||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Composition;
|
||||
using NzbDrone.Common.EnsureThat;
|
||||
using NzbDrone.Common.Serializer;
|
||||
|
||||
namespace NzbDrone.Common.Messaging
|
||||
{
|
||||
[Singleton]
|
||||
public class MessageAggregator : IMessageAggregator
|
||||
{
|
||||
private readonly Logger _logger;
|
||||
|
|
|
@ -83,7 +83,6 @@
|
|||
<Compile Include="Cache\ICached.cs" />
|
||||
<Compile Include="Composition\Container.cs" />
|
||||
<Compile Include="Composition\IContainer.cs" />
|
||||
<Compile Include="Composition\SingletonAttribute.cs" />
|
||||
<Compile Include="Composition\ContainerBuilderBase.cs" />
|
||||
<Compile Include="EnsureThat\Ensure.cs" />
|
||||
<Compile Include="EnsureThat\EnsureBoolExtensions.cs" />
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
using System.Data.SQLite;
|
||||
using Marr.Data;
|
||||
using Marr.Data.Reflection;
|
||||
using NzbDrone.Common.Composition;
|
||||
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||
|
||||
|
||||
|
@ -13,7 +12,6 @@ namespace NzbDrone.Core.Datastore
|
|||
IDatabase Create(string dbPath, MigrationType migrationType = MigrationType.Main);
|
||||
}
|
||||
|
||||
[Singleton]
|
||||
public class DbFactory : IDbFactory
|
||||
{
|
||||
private readonly IMigrationController _migrationController;
|
||||
|
|
|
@ -5,7 +5,6 @@ using NzbDrone.Common.Composition;
|
|||
|
||||
namespace NzbDrone.Core.Datastore.Migration.Framework
|
||||
{
|
||||
[Singleton]
|
||||
public class MigrationLogger : IAnnouncer
|
||||
{
|
||||
private readonly Logger _logger;
|
||||
|
|
|
@ -9,7 +9,6 @@ using Timer = System.Timers.Timer;
|
|||
|
||||
namespace NzbDrone.Core.Jobs
|
||||
{
|
||||
[Singleton]
|
||||
public class Scheduler :
|
||||
IHandle<ApplicationStartedEvent>,
|
||||
IHandle<ApplicationShutdownRequested>
|
||||
|
|
|
@ -9,7 +9,6 @@ using IServiceProvider = NzbDrone.Common.IServiceProvider;
|
|||
|
||||
namespace NzbDrone
|
||||
{
|
||||
[Singleton]
|
||||
public class Router
|
||||
{
|
||||
private readonly INzbDroneServiceFactory _nzbDroneServiceFactory;
|
||||
|
|
Loading…
Reference in New Issue