diff --git a/NzbDrone.Api/NancyBootstrapper.cs b/NzbDrone.Api/NancyBootstrapper.cs index 2de87f802..4907ff34b 100644 --- a/NzbDrone.Api/NancyBootstrapper.cs +++ b/NzbDrone.Api/NancyBootstrapper.cs @@ -19,7 +19,6 @@ namespace NzbDrone.Api { - [Singleton] public class NancyBootstrapper : TinyIoCNancyBootstrapper { private readonly TinyIoCContainer _tinyIoCContainer; diff --git a/NzbDrone.Api/SignalR/Serializer.cs b/NzbDrone.Api/SignalR/Serializer.cs index b0ffb9847..4ab2bfc01 100644 --- a/NzbDrone.Api/SignalR/Serializer.cs +++ b/NzbDrone.Api/SignalR/Serializer.cs @@ -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(); diff --git a/NzbDrone.Common/Composition/Container.cs b/NzbDrone.Common/Composition/Container.cs index 1afa9d3b6..73c3a2833 100644 --- a/NzbDrone.Common/Composition/Container.cs +++ b/NzbDrone.Common/Composition/Container.cs @@ -86,9 +86,9 @@ public void Register(Type registrationType, object instance) _container.Register(registrationType, instance); } - public void RegisterAll(Type registrationType, IEnumerable implementationList) + public void RegisterAllAsSingleton(Type registrationType, IEnumerable implementationList) { - _container.RegisterMultiple(registrationType, implementationList); + _container.RegisterMultiple(registrationType, implementationList).AsSingleton(); } public bool IsTypeRegistered(Type type) diff --git a/NzbDrone.Common/Composition/ContainerBuilderBase.cs b/NzbDrone.Common/Composition/ContainerBuilderBase.cs index 14b6f6400..6c40737ac 100644 --- a/NzbDrone.Common/Composition/ContainerBuilderBase.cs +++ b/NzbDrone.Common/Composition/ContainerBuilderBase.cs @@ -64,22 +64,12 @@ private void AutoRegisterImplementations(Type contractType) var impl = implementations.Single(); Trace.WriteLine(string.Format("Registering {0} -> {1}", contractType.FullName, impl.Name)); - - - if (impl.HasAttribute()) - { - 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); } } diff --git a/NzbDrone.Common/Composition/IContainer.cs b/NzbDrone.Common/Composition/IContainer.cs index f1b3c0001..e65009f24 100644 --- a/NzbDrone.Common/Composition/IContainer.cs +++ b/NzbDrone.Common/Composition/IContainer.cs @@ -24,7 +24,7 @@ void RegisterSingleton() IEnumerable ResolveAll() where T : class; IEnumerable ResolveAll(Type type); void Register(Type registrationType, object instance); - void RegisterAll(Type registrationType, IEnumerable implementationList); + void RegisterAllAsSingleton(Type registrationType, IEnumerable implementationList); bool IsTypeRegistered(Type type); IEnumerable GetImplementations(Type contractType); diff --git a/NzbDrone.Common/Composition/SingletonAttribute.cs b/NzbDrone.Common/Composition/SingletonAttribute.cs deleted file mode 100644 index bf9272525..000000000 --- a/NzbDrone.Common/Composition/SingletonAttribute.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace NzbDrone.Common.Composition -{ - public class SingletonAttribute : Attribute - { - } -} \ No newline at end of file diff --git a/NzbDrone.Common/Messaging/MessageAggregator.cs b/NzbDrone.Common/Messaging/MessageAggregator.cs index 825fe3b42..2a325e177 100644 --- a/NzbDrone.Common/Messaging/MessageAggregator.cs +++ b/NzbDrone.Common/Messaging/MessageAggregator.cs @@ -3,13 +3,11 @@ 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; diff --git a/NzbDrone.Common/NzbDrone.Common.csproj b/NzbDrone.Common/NzbDrone.Common.csproj index 2429b32a2..51955f90b 100644 --- a/NzbDrone.Common/NzbDrone.Common.csproj +++ b/NzbDrone.Common/NzbDrone.Common.csproj @@ -83,7 +83,6 @@ - diff --git a/NzbDrone.Core/Datastore/DbFactory.cs b/NzbDrone.Core/Datastore/DbFactory.cs index d45977514..40ed7965e 100644 --- a/NzbDrone.Core/Datastore/DbFactory.cs +++ b/NzbDrone.Core/Datastore/DbFactory.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 @@ public interface IDbFactory IDatabase Create(string dbPath, MigrationType migrationType = MigrationType.Main); } - [Singleton] public class DbFactory : IDbFactory { private readonly IMigrationController _migrationController; diff --git a/NzbDrone.Core/Datastore/Migration/Framework/MigrationLogger.cs b/NzbDrone.Core/Datastore/Migration/Framework/MigrationLogger.cs index af52275e0..a1761c830 100644 --- a/NzbDrone.Core/Datastore/Migration/Framework/MigrationLogger.cs +++ b/NzbDrone.Core/Datastore/Migration/Framework/MigrationLogger.cs @@ -5,7 +5,6 @@ namespace NzbDrone.Core.Datastore.Migration.Framework { - [Singleton] public class MigrationLogger : IAnnouncer { private readonly Logger _logger; diff --git a/NzbDrone.Core/Jobs/Scheduler.cs b/NzbDrone.Core/Jobs/Scheduler.cs index 77a9e6df0..0fe50bcaf 100644 --- a/NzbDrone.Core/Jobs/Scheduler.cs +++ b/NzbDrone.Core/Jobs/Scheduler.cs @@ -9,7 +9,6 @@ namespace NzbDrone.Core.Jobs { - [Singleton] public class Scheduler : IHandle, IHandle diff --git a/NzbDrone/Router.cs b/NzbDrone/Router.cs index 9b248ff01..fe56b44dc 100644 --- a/NzbDrone/Router.cs +++ b/NzbDrone/Router.cs @@ -9,7 +9,6 @@ namespace NzbDrone { - [Singleton] public class Router { private readonly INzbDroneServiceFactory _nzbDroneServiceFactory;