From 924d3d0c8ec216c59f9710d1891a51faf254dc05 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Wed, 2 Jan 2013 17:09:13 -0800 Subject: [PATCH 1/6] Hello Autofac, Goodbye Ninject --- NzbDrone.Api/AppHost.cs | 11 +- NzbDrone.Api/AutofacContainerAdapter.cs | 36 ++++ .../Filters/ValidApiRequestAttribute.cs | 2 - NzbDrone.Api/NzbDrone.Api.csproj | 14 +- .../QualityProfiles/QualityProfileService.cs | 2 - .../QualityType/QualityTypeService.cs | 2 - NzbDrone.Api/packages.config | 3 +- NzbDrone.App.Test/CentralDispatchTests.cs | 16 +- NzbDrone.App.Test/IISProviderFixture.cs | 3 +- NzbDrone.App.Test/NzbDrone.App.Test.csproj | 10 +- NzbDrone.App.Test/packages.config | 2 +- .../NzbDrone.Common.Test.csproj | 10 +- NzbDrone.Common.Test/packages.config | 2 +- NzbDrone.Common/ConfigFileProvider.cs | 2 - NzbDrone.Common/HttpProvider.cs | 2 - NzbDrone.Common/IISProvider.cs | 2 - NzbDrone.Common/NzbDrone.Common.csproj | 10 +- NzbDrone.Common/RestProvider.cs | 2 - NzbDrone.Common/SecurityProvider.cs | 2 - NzbDrone.Common/packages.config | 2 +- NzbDrone.Core.Test/CentralDispatchFixture.cs | 24 ++- NzbDrone.Core.Test/Framework/CoreTest.cs | 1 - .../ConvertToDayOfWeekFixture.cs | 1 - .../ServiceIntegerationFixture.cs | 23 +- NzbDrone.Core.Test/NzbDrone.Core.Test.csproj | 10 +- .../JobProviderTests/JobProviderFixture.cs | 46 ++-- .../ProviderTests/TvDbProviderTest.cs | 11 +- .../TvRageProviderTests/GetSeriesFixture.cs | 1 - .../GetUtcOffsetFixture.cs | 1 - .../SearchSeriesFixture.cs | 1 - NzbDrone.Core.Test/packages.config | 2 +- .../AutofacSignalrDependencyResolver.cs | 94 ++++++++ NzbDrone.Core/CentralDispatch.cs | 204 ++++++++++-------- .../Instrumentation/DatabaseTarget.cs | 2 - NzbDrone.Core/Instrumentation/LogDbContext.cs | 2 - NzbDrone.Core/Jobs/AppUpdateJob.cs | 2 - NzbDrone.Core/Jobs/BacklogSearchJob.cs | 2 - NzbDrone.Core/Jobs/BannerDownloadJob.cs | 2 - NzbDrone.Core/Jobs/CleanupRecycleBinJob.cs | 2 - NzbDrone.Core/Jobs/ConvertEpisodeJob.cs | 2 - NzbDrone.Core/Jobs/DeleteSeriesJob.cs | 2 - NzbDrone.Core/Jobs/DiskScanJob.cs | 2 - NzbDrone.Core/Jobs/EmptyRecycleBinJob.cs | 2 - NzbDrone.Core/Jobs/EpisodeSearchJob.cs | 2 - NzbDrone.Core/Jobs/ImportNewSeriesJob.cs | 2 - NzbDrone.Core/Jobs/JobProvider.cs | 6 +- .../Jobs/PastWeekBacklogSearchJob.cs | 2 - NzbDrone.Core/Jobs/PostDownloadScanJob.cs | 2 - NzbDrone.Core/Jobs/RecentBacklogSearchJob.cs | 2 - NzbDrone.Core/Jobs/RefreshEpsiodeMetadata.cs | 2 - NzbDrone.Core/Jobs/RenameSeasonJob.cs | 2 - NzbDrone.Core/Jobs/RenameSeriesJob.cs | 2 - NzbDrone.Core/Jobs/RssSyncJob.cs | 2 - NzbDrone.Core/Jobs/SearchHistoryCleanupJob.cs | 2 - NzbDrone.Core/Jobs/SeasonSearchJob.cs | 2 - NzbDrone.Core/Jobs/SeriesSearchJob.cs | 2 - NzbDrone.Core/Jobs/TrimLogsJob.cs | 2 - NzbDrone.Core/Jobs/UpdateInfoJob.cs | 2 - NzbDrone.Core/Jobs/UpdateSceneMappingsJob.cs | 2 - NzbDrone.Core/Jobs/XemUpdateJob.cs | 2 - NzbDrone.Core/NinjectDependencyResolver.cs | 34 --- NzbDrone.Core/NzbDrone.Core.csproj | 12 +- NzbDrone.Core/Providers/BackupProvider.cs | 2 - NzbDrone.Core/Providers/BannerProvider.cs | 2 - .../Providers/Core/ArchiveProvider.cs | 1 - .../Providers/Core/ConfigProvider.cs | 2 - NzbDrone.Core/Providers/Core/UdpProvider.cs | 2 - .../AcceptableSizeSpecification.cs | 2 - .../AllowedDownloadSpecification.cs | 2 - .../AllowedReleaseGroupSpecification.cs | 2 - .../AlreadyInQueueSpecification.cs | 2 - .../CustomStartDateSpecification.cs | 1 - .../MonitoredEpisodeSpecification.cs | 2 - .../DecisionEngine/RetentionSpecification.cs | 2 - .../UpgradeDiskSpecification.cs | 2 - .../UpgradeHistorySpecification.cs | 2 - .../UpgradePossibleSpecification.cs | 2 - NzbDrone.Core/Providers/DiskScanProvider.cs | 2 - .../DownloadClients/BlackholeProvider.cs | 2 - .../DownloadClients/PneumaticProvider.cs | 2 - .../Providers/DownloadClients/SabProvider.cs | 2 - NzbDrone.Core/Providers/DownloadProvider.cs | 2 - NzbDrone.Core/Providers/EpisodeProvider.cs | 2 - .../Providers/ExternalNotificationProvider.cs | 2 - NzbDrone.Core/Providers/HistoryProvider.cs | 2 - .../Providers/Indexer/FileSharingTalk.cs | 2 - .../Providers/Indexer/IndexerBase.cs | 2 - NzbDrone.Core/Providers/Indexer/Newznab.cs | 2 - NzbDrone.Core/Providers/Indexer/NzbClub.cs | 2 - NzbDrone.Core/Providers/Indexer/NzbIndex.cs | 2 - NzbDrone.Core/Providers/Indexer/NzbsRUs.cs | 2 - NzbDrone.Core/Providers/Indexer/Nzbx.cs | 2 - NzbDrone.Core/Providers/Indexer/Omgwtfnzbs.cs | 2 - NzbDrone.Core/Providers/Indexer/Wombles.cs | 2 - NzbDrone.Core/Providers/IndexerProvider.cs | 2 - NzbDrone.Core/Providers/MediaFileProvider.cs | 2 - NzbDrone.Core/Providers/MetadataProvider.cs | 2 - NzbDrone.Core/Providers/NewznabProvider.cs | 2 - NzbDrone.Core/Providers/PlexProvider.cs | 2 - .../Providers/PostDownloadProvider.cs | 2 - NzbDrone.Core/Providers/QualityProvider.cs | 2 - NzbDrone.Core/Providers/RecycleBinProvider.cs | 2 - NzbDrone.Core/Providers/RootDirProvider.cs | 2 - .../Providers/SceneMappingProvider.cs | 2 - .../Providers/SearchHistoryProvider.cs | 2 - NzbDrone.Core/Providers/SearchProvider.cs | 2 - NzbDrone.Core/Providers/SeasonProvider.cs | Bin 7138 -> 7104 bytes NzbDrone.Core/Providers/SeriesProvider.cs | 2 - NzbDrone.Core/Providers/SignalRProvider.cs | 1 - NzbDrone.Core/Providers/SmtpProvider.cs | 2 - NzbDrone.Core/Providers/StatsProvider.cs | 2 - NzbDrone.Core/Providers/TvDbProvider.cs | 2 - .../Providers/TvRageMappingProvider.cs | 2 - NzbDrone.Core/Providers/TvRageProvider.cs | 2 - NzbDrone.Core/Providers/TwitterProvider.cs | 2 - .../Providers/UpcomingEpisodesProvider.cs | 2 - NzbDrone.Core/Providers/UpdateProvider.cs | 2 - .../Providers/Xbmc/EventClientProvider.cs | 2 - NzbDrone.Core/Providers/XbmcProvider.cs | 2 - .../Providers/XemCommunicationProvider.cs | 2 - NzbDrone.Core/Providers/XemProvider.cs | 2 - NzbDrone.Core/packages.config | 2 +- .../App_Start/NinjectWebCommon.cs | 65 ------ .../NzbDrone.Services.Service/Global.asax.cs | 30 +++ .../NzbDrone.Services.Service.csproj | 21 +- .../NzbDrone.Services.Service/packages.config | 5 +- NzbDrone.Update/NzbDrone.Update.csproj | 8 +- NzbDrone.Update/Program.cs | 18 +- NzbDrone.Update/Providers/UpdateProvider.cs | 2 - NzbDrone.Update/packages.config | 2 +- NzbDrone.Web/Global.asax.cs | 37 +++- NzbDrone.Web/NzbDrone.Web.csproj | 20 +- NzbDrone.Web/packages.config | 7 +- NzbDrone/AppMain.cs | 6 +- NzbDrone/ApplicationServer.cs | 2 - NzbDrone/CentralDispatch.cs | 43 ++-- NzbDrone/NzbDrone.csproj | 10 +- NzbDrone/Providers/MonitoringProvider.cs | 2 - NzbDrone/packages.config | 2 +- 139 files changed, 477 insertions(+), 576 deletions(-) create mode 100644 NzbDrone.Api/AutofacContainerAdapter.cs create mode 100644 NzbDrone.Core/AutofacSignalrDependencyResolver.cs delete mode 100644 NzbDrone.Core/NinjectDependencyResolver.cs delete mode 100644 NzbDrone.Services/NzbDrone.Services.Service/App_Start/NinjectWebCommon.cs diff --git a/NzbDrone.Api/AppHost.cs b/NzbDrone.Api/AppHost.cs index 247bc784e..f39b2f373 100644 --- a/NzbDrone.Api/AppHost.cs +++ b/NzbDrone.Api/AppHost.cs @@ -3,11 +3,10 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Web; +using Autofac; using Funq; -using Ninject; using NzbDrone.Api.QualityProfiles; using NzbDrone.Api.QualityType; -using ServiceStack.ContainerAdapter.Ninject; using ServiceStack.WebHost.Endpoints; using QualityProfileService = NzbDrone.Api.QualityProfiles.QualityProfileService; @@ -15,17 +14,17 @@ namespace NzbDrone.Api { public class AppHost : AppHostBase { - private IKernel _kernel; + private IContainer _container; - public AppHost(IKernel kernel) //Tell ServiceStack the name and where to find your web services + public AppHost(IContainer container) //Tell ServiceStack the name and where to find your web services : base("NzbDrone API", typeof(QualityProfileService).Assembly) { - _kernel = kernel; + _container = container; } public override void Configure(Container container) { - container.Adapter = new NinjectContainerAdapter(_kernel); + container.Adapter = new AutofacIocAdapter(_container); SetConfig(new EndpointHostConfig { ServiceStackHandlerFactoryPath = "api" }); Routes diff --git a/NzbDrone.Api/AutofacContainerAdapter.cs b/NzbDrone.Api/AutofacContainerAdapter.cs new file mode 100644 index 000000000..945ea4657 --- /dev/null +++ b/NzbDrone.Api/AutofacContainerAdapter.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Autofac; +using ServiceStack.Configuration; + +namespace NzbDrone.Api +{ + public class AutofacIocAdapter : IContainerAdapter + { + private readonly IContainer _container; + + public AutofacIocAdapter(IContainer container) + { + _container = container; + } + + public T Resolve() + { + return _container.Resolve(); + } + + public T TryResolve() + { + T result; + + if (_container.TryResolve(out result)) + { + return result; + } + + return default(T); + } + } +} diff --git a/NzbDrone.Api/Filters/ValidApiRequestAttribute.cs b/NzbDrone.Api/Filters/ValidApiRequestAttribute.cs index 3b15ffbd5..7a2396962 100644 --- a/NzbDrone.Api/Filters/ValidApiRequestAttribute.cs +++ b/NzbDrone.Api/Filters/ValidApiRequestAttribute.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using Ninject; using NzbDrone.Api.Exceptions; using NzbDrone.Api.Helpers; using NzbDrone.Core.Providers.Core; @@ -16,7 +15,6 @@ namespace NzbDrone.Api.Filters public ApplyTo ApplyTo { get; set; } public int Priority { get; set; } - [Inject] public ConfigProvider _configProvider; public void RequestFilter(IHttpRequest req, IHttpResponse res, object requestDto) diff --git a/NzbDrone.Api/NzbDrone.Api.csproj b/NzbDrone.Api/NzbDrone.Api.csproj index 93638f9c5..69f3d1c34 100644 --- a/NzbDrone.Api/NzbDrone.Api.csproj +++ b/NzbDrone.Api/NzbDrone.Api.csproj @@ -50,22 +50,21 @@ MinimumRecommendedRules.ruleset + + ..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.dll + + + ..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.Configuration.dll + ..\packages\AutoMapper.2.2.0\lib\net40\AutoMapper.dll - - False - ..\packages\Ninject.3.0.1.10\lib\net40\Ninject.dll - ..\packages\ServiceStack.3.9.25\lib\net35\ServiceStack.dll ..\packages\ServiceStack.Common.3.9.25\lib\net35\ServiceStack.Common.dll - - ..\packages\ServiceStack.ContainerAdapter.Ninject.1.0.4526.38581\lib\net40\ServiceStack.ContainerAdapter.Ninject.dll - ..\packages\ServiceStack.Common.3.9.25\lib\net35\ServiceStack.Interfaces.dll @@ -94,6 +93,7 @@ + diff --git a/NzbDrone.Api/QualityProfiles/QualityProfileService.cs b/NzbDrone.Api/QualityProfiles/QualityProfileService.cs index 370ed7067..960f79f65 100644 --- a/NzbDrone.Api/QualityProfiles/QualityProfileService.cs +++ b/NzbDrone.Api/QualityProfiles/QualityProfileService.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.Linq; using AutoMapper; -using Ninject; using NzbDrone.Api.Filters; using NzbDrone.Core.Providers; using NzbDrone.Core.Repository.Quality; @@ -14,7 +13,6 @@ namespace NzbDrone.Api.QualityProfiles { private readonly QualityProvider _qualityProvider; - [Inject] public QualityProfileService(QualityProvider qualityProvider) { _qualityProvider = qualityProvider; diff --git a/NzbDrone.Api/QualityType/QualityTypeService.cs b/NzbDrone.Api/QualityType/QualityTypeService.cs index def3b9cfb..d1dff6bdd 100644 --- a/NzbDrone.Api/QualityType/QualityTypeService.cs +++ b/NzbDrone.Api/QualityType/QualityTypeService.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using AutoMapper; -using Ninject; using NzbDrone.Api.Filters; using NzbDrone.Core.Providers; using ServiceStack.ServiceInterface; @@ -14,7 +13,6 @@ namespace NzbDrone.Api.QualityType { private readonly QualityTypeProvider _qualityTypeProvider; - [Inject] public QualityTypeService(QualityTypeProvider qualityTypeProvider) { _qualityTypeProvider = qualityTypeProvider; diff --git a/NzbDrone.Api/packages.config b/NzbDrone.Api/packages.config index b382dd46c..bb58ee857 100644 --- a/NzbDrone.Api/packages.config +++ b/NzbDrone.Api/packages.config @@ -1,10 +1,9 @@  + - - diff --git a/NzbDrone.App.Test/CentralDispatchTests.cs b/NzbDrone.App.Test/CentralDispatchTests.cs index 5b7ccd1c0..b27dac6c2 100644 --- a/NzbDrone.App.Test/CentralDispatchTests.cs +++ b/NzbDrone.App.Test/CentralDispatchTests.cs @@ -1,6 +1,6 @@ -using FluentAssertions; +using Autofac; +using FluentAssertions; using NUnit.Framework; -using Ninject; using NzbDrone.Test.Common; namespace NzbDrone.App.Test @@ -11,14 +11,14 @@ namespace NzbDrone.App.Test [Test] public void Kernel_can_get_kernel() { - CentralDispatch.Kernel.Should().NotBeNull(); + CentralDispatch.Container.Should().NotBeNull(); } [Test] public void Kernel_should_return_same_kernel() { - var firstKernel = CentralDispatch.Kernel; - var secondKernel = CentralDispatch.Kernel; + var firstKernel = CentralDispatch.Container; + var secondKernel = CentralDispatch.Container; firstKernel.Should().BeSameAs(secondKernel); } @@ -26,7 +26,7 @@ namespace NzbDrone.App.Test [Test] public void Kernel_should_be_able_to_resolve_ApplicationServer() { - var appServer = CentralDispatch.Kernel.Get(); + var appServer = CentralDispatch.Container.Resolve(); appServer.Should().NotBeNull(); } @@ -34,8 +34,8 @@ namespace NzbDrone.App.Test [Test] public void Kernel_should_resolve_same_ApplicationServer_instance() { - var appServer1 = CentralDispatch.Kernel.Get(); - var appServer2 = CentralDispatch.Kernel.Get(); + var appServer1 = CentralDispatch.Container.Resolve(); + var appServer2 = CentralDispatch.Container.Resolve(); appServer1.Should().BeSameAs(appServer2); } diff --git a/NzbDrone.App.Test/IISProviderFixture.cs b/NzbDrone.App.Test/IISProviderFixture.cs index 197386d96..b63e378cc 100644 --- a/NzbDrone.App.Test/IISProviderFixture.cs +++ b/NzbDrone.App.Test/IISProviderFixture.cs @@ -3,8 +3,7 @@ //using FluentAssertions; //using Moq; //using NUnit.Framework; -//using Ninject; -//using NzbDrone.Common; +////using NzbDrone.Common; //using NzbDrone.Common.Model; //using NzbDrone.Providers; //using NzbDrone.Test.Common; diff --git a/NzbDrone.App.Test/NzbDrone.App.Test.csproj b/NzbDrone.App.Test/NzbDrone.App.Test.csproj index b7b81f146..43f06920b 100644 --- a/NzbDrone.App.Test/NzbDrone.App.Test.csproj +++ b/NzbDrone.App.Test/NzbDrone.App.Test.csproj @@ -53,6 +53,12 @@ MinimumRecommendedRules.ruleset + + ..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.dll + + + ..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.Configuration.dll + ..\packages\NBuilder.3.0.1.1\lib\FizzWare.NBuilder.dll @@ -63,10 +69,6 @@ ..\packages\Moq.4.0.10827\lib\NET40\Moq.dll - - False - ..\packages\Ninject.3.0.1.10\lib\net40\Ninject.dll - ..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll diff --git a/NzbDrone.App.Test/packages.config b/NzbDrone.App.Test/packages.config index e819227a6..5bdf4ab75 100644 --- a/NzbDrone.App.Test/packages.config +++ b/NzbDrone.App.Test/packages.config @@ -1,9 +1,9 @@  + - \ No newline at end of file diff --git a/NzbDrone.Common.Test/NzbDrone.Common.Test.csproj b/NzbDrone.Common.Test/NzbDrone.Common.Test.csproj index b4ae5d76a..4debf09c5 100644 --- a/NzbDrone.Common.Test/NzbDrone.Common.Test.csproj +++ b/NzbDrone.Common.Test/NzbDrone.Common.Test.csproj @@ -53,6 +53,12 @@ MinimumRecommendedRules.ruleset + + ..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.dll + + + ..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.Configuration.dll + False ..\packages\FluentAssertions.1.7.0\Lib\net40\FluentAssertions.dll @@ -60,10 +66,6 @@ ..\packages\Moq.4.0.10827\lib\NET40\Moq.dll - - False - ..\packages\Ninject.3.0.1.10\lib\net40\Ninject.dll - ..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll diff --git a/NzbDrone.Common.Test/packages.config b/NzbDrone.Common.Test/packages.config index 701efa0d2..6b546d3f9 100644 --- a/NzbDrone.Common.Test/packages.config +++ b/NzbDrone.Common.Test/packages.config @@ -1,8 +1,8 @@  + - \ No newline at end of file diff --git a/NzbDrone.Common/ConfigFileProvider.cs b/NzbDrone.Common/ConfigFileProvider.cs index ee9b8c6dc..4238892a2 100644 --- a/NzbDrone.Common/ConfigFileProvider.cs +++ b/NzbDrone.Common/ConfigFileProvider.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Xml.Linq; using System.Xml.XPath; using NLog; -using Ninject; using NzbDrone.Common.Model; namespace NzbDrone.Common @@ -16,7 +15,6 @@ namespace NzbDrone.Common private readonly string _configFile; - [Inject] public ConfigFileProvider(EnvironmentProvider environmentProvider) { _environmentProvider = environmentProvider; diff --git a/NzbDrone.Common/HttpProvider.cs b/NzbDrone.Common/HttpProvider.cs index 73bf45f12..04c7a074f 100644 --- a/NzbDrone.Common/HttpProvider.cs +++ b/NzbDrone.Common/HttpProvider.cs @@ -5,7 +5,6 @@ using System.IO; using System.Net; using System.Text; using NLog; -using Ninject; namespace NzbDrone.Common { @@ -14,7 +13,6 @@ namespace NzbDrone.Common private readonly EnvironmentProvider _environmentProvider; private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - [Inject] public HttpProvider(EnvironmentProvider environmentProvider) { _environmentProvider = environmentProvider; diff --git a/NzbDrone.Common/IISProvider.cs b/NzbDrone.Common/IISProvider.cs index b04952dc6..c2f170ac3 100644 --- a/NzbDrone.Common/IISProvider.cs +++ b/NzbDrone.Common/IISProvider.cs @@ -2,7 +2,6 @@ using System; using System.Diagnostics; using NLog; -using Ninject; namespace NzbDrone.Common { @@ -15,7 +14,6 @@ namespace NzbDrone.Common private readonly EnvironmentProvider _environmentProvider; - [Inject] public IISProvider(ConfigFileProvider configFileProvider, ProcessProvider processProvider, EnvironmentProvider environmentProvider) { _configFileProvider = configFileProvider; diff --git a/NzbDrone.Common/NzbDrone.Common.csproj b/NzbDrone.Common/NzbDrone.Common.csproj index a770bfcf8..c7a29d920 100644 --- a/NzbDrone.Common/NzbDrone.Common.csproj +++ b/NzbDrone.Common/NzbDrone.Common.csproj @@ -53,6 +53,12 @@ MinimumRecommendedRules.ruleset + + ..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.dll + + + ..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.Configuration.dll + False ..\packages\Exceptron.Client.1.0.7\lib\net20\Exceptron.Client.dll @@ -61,10 +67,6 @@ False ..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll - - False - ..\packages\Ninject.3.0.1.10\lib\net40\Ninject.dll - ..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll diff --git a/NzbDrone.Common/RestProvider.cs b/NzbDrone.Common/RestProvider.cs index 390638264..9ebb56a0e 100644 --- a/NzbDrone.Common/RestProvider.cs +++ b/NzbDrone.Common/RestProvider.cs @@ -5,7 +5,6 @@ using System.Net; using System.Text; using NLog; using Newtonsoft.Json; -using Ninject; using NzbDrone.Common.Contract; namespace NzbDrone.Common @@ -19,7 +18,6 @@ namespace NzbDrone.Common private readonly EnvironmentProvider _environmentProvider; - [Inject] public RestProvider(EnvironmentProvider environmentProvider) { _environmentProvider = environmentProvider; diff --git a/NzbDrone.Common/SecurityProvider.cs b/NzbDrone.Common/SecurityProvider.cs index be4abc2b0..d918af749 100644 --- a/NzbDrone.Common/SecurityProvider.cs +++ b/NzbDrone.Common/SecurityProvider.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Security.Principal; using NLog; using NetFwTypeLib; -using Ninject; namespace NzbDrone.Common { @@ -16,7 +15,6 @@ namespace NzbDrone.Common private readonly EnvironmentProvider _environmentProvider; private readonly ProcessProvider _processProvider; - [Inject] public SecurityProvider(ConfigFileProvider configFileProvider, EnvironmentProvider environmentProvider, ProcessProvider processProvider) { diff --git a/NzbDrone.Common/packages.config b/NzbDrone.Common/packages.config index f6c80b659..5490096a8 100644 --- a/NzbDrone.Common/packages.config +++ b/NzbDrone.Common/packages.config @@ -1,7 +1,7 @@  + - \ No newline at end of file diff --git a/NzbDrone.Core.Test/CentralDispatchFixture.cs b/NzbDrone.Core.Test/CentralDispatchFixture.cs index 8ec3a2012..8b88af2b2 100644 --- a/NzbDrone.Core.Test/CentralDispatchFixture.cs +++ b/NzbDrone.Core.Test/CentralDispatchFixture.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Autofac; using FluentAssertions; using NUnit.Framework; using NzbDrone.Common; @@ -9,7 +10,6 @@ using NzbDrone.Core.Jobs; using NzbDrone.Core.Providers; using NzbDrone.Core.Providers.Indexer; using NzbDrone.Core.Test.Framework; -using Ninject; namespace NzbDrone.Core.Test { @@ -19,12 +19,14 @@ namespace NzbDrone.Core.Test readonly IList indexers = typeof(CentralDispatch).Assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(IndexerBase))).ToList(); readonly IList jobs = typeof(CentralDispatch).Assembly.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IJob))).ToList(); - private IKernel kernel; + private IContainer kernel; public CentralDispatchFixture() { InitLogging(); - kernel = new CentralDispatch().Kernel; + var dispatch = new CentralDispatch(); + kernel = dispatch.Build(); + WebTimer.Stop(); } @@ -44,7 +46,7 @@ namespace NzbDrone.Core.Test foreach (var provider in providers) { Console.WriteLine("Resolving " + provider.Name); - kernel.Get(provider).Should().NotBeNull(); + kernel.Resolve(provider).Should().NotBeNull(); } } @@ -54,7 +56,7 @@ namespace NzbDrone.Core.Test { //Assert - var registeredJobs = kernel.GetAll(); + var registeredJobs = kernel.Resolve>(); jobs.Should().NotBeEmpty(); @@ -67,7 +69,7 @@ namespace NzbDrone.Core.Test { //Assert - var registeredIndexers = kernel.GetAll(); + var registeredIndexers = kernel.Resolve>(); indexers.Should().NotBeEmpty(); @@ -78,26 +80,26 @@ namespace NzbDrone.Core.Test [Test] public void jobs_are_initialized() { - kernel.Get().All().Should().HaveSameCount(jobs); + kernel.Resolve().All().Should().HaveSameCount(jobs); } [Test] public void indexers_are_initialized() { - kernel.Get().All().Should().HaveSameCount(indexers); + kernel.Resolve().All().Should().HaveSameCount(indexers); } [Test] public void quality_profile_initialized() { - kernel.Get().All().Should().HaveCount(2); + kernel.Resolve().All().Should().HaveCount(2); } [Test] public void JobProvider_should_be_singletone() { - var first = kernel.Get(); - var second = kernel.Get(); + var first = kernel.Resolve(); + var second = kernel.Resolve(); first.Should().BeSameAs(second); } diff --git a/NzbDrone.Core.Test/Framework/CoreTest.cs b/NzbDrone.Core.Test/Framework/CoreTest.cs index 9f63d02f7..3bd7f899b 100644 --- a/NzbDrone.Core.Test/Framework/CoreTest.cs +++ b/NzbDrone.Core.Test/Framework/CoreTest.cs @@ -54,7 +54,6 @@ namespace NzbDrone.Core.Test.Framework Mocker.SetConstant(Db); } - protected static ProgressNotification MockNotification { get diff --git a/NzbDrone.Core.Test/HelperTests/XElementHelperTests/ConvertToDayOfWeekFixture.cs b/NzbDrone.Core.Test/HelperTests/XElementHelperTests/ConvertToDayOfWeekFixture.cs index 424c8f4a1..1ba43c3fd 100644 --- a/NzbDrone.Core.Test/HelperTests/XElementHelperTests/ConvertToDayOfWeekFixture.cs +++ b/NzbDrone.Core.Test/HelperTests/XElementHelperTests/ConvertToDayOfWeekFixture.cs @@ -6,7 +6,6 @@ using System.Linq; using System.Xml.Linq; using FluentAssertions; using NUnit.Framework; -using Ninject; using NzbDrone.Common; using NzbDrone.Core.Helpers; using NzbDrone.Core.Providers; diff --git a/NzbDrone.Core.Test/Integeration/ServiceIntegerationFixture.cs b/NzbDrone.Core.Test/Integeration/ServiceIntegerationFixture.cs index f65a20adb..da30f5431 100644 --- a/NzbDrone.Core.Test/Integeration/ServiceIntegerationFixture.cs +++ b/NzbDrone.Core.Test/Integeration/ServiceIntegerationFixture.cs @@ -1,11 +1,12 @@ using System; using System.Data; using System.Linq; +using Autofac; using FluentAssertions; using NLog; using NUnit.Framework; -using Ninject; using NzbDrone.Common; +using NzbDrone.Core.Datastore; using NzbDrone.Core.Providers; using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Repository; @@ -17,24 +18,27 @@ namespace NzbDrone.Core.Test.Integeration [TestFixture(Category = "ServiceIngeneration")] public class ServiceIntegerationFixture : CoreTest { - private KernelBase _kernel; + private IContainer _container; [SetUp] public void Setup() { WithRealDb(); - _kernel = new StandardKernel(); - _kernel.Bind().ToConstant(Db); + var builder = new CentralDispatch().ContainerBuilder; + + builder.Register(c => Db) + .As(); + + _container = builder.Build(); Mocker.GetMock().SetupGet(s => s.ServiceRootUrl) .Returns("http://services.nzbdrone.com"); - } [Test] public void should_be_able_to_update_scene_mapping() { - _kernel.Get().UpdateMappings(); + _container.Resolve().UpdateMappings(); var mappings = Db.Fetch(); mappings.Should().NotBeEmpty(); @@ -47,7 +51,7 @@ namespace NzbDrone.Core.Test.Integeration [Test] public void should_be_able_to_get_daily_series_ids() { - var dailySeries = _kernel.Get().GetDailySeriesIds(); + var dailySeries = _container.Resolve().GetDailySeriesIds(); dailySeries.Should().NotBeEmpty(); dailySeries.Should().OnlyContain(c => c > 0); @@ -76,11 +80,6 @@ namespace NzbDrone.Core.Test.Integeration hash.Should().HaveLength(8); } - - } - - - } } \ No newline at end of file diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 5b5fd5f12..3c1b49c32 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -56,6 +56,12 @@ True + + ..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.dll + + + ..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.Configuration.dll + ..\packages\AutoMoq.1.6.1\lib\AutoMoq.dll @@ -97,10 +103,6 @@ False ..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll - - False - ..\packages\Ninject.3.0.1.10\lib\net40\Ninject.dll - ..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll diff --git a/NzbDrone.Core.Test/ProviderTests/JobProviderTests/JobProviderFixture.cs b/NzbDrone.Core.Test/ProviderTests/JobProviderTests/JobProviderFixture.cs index 2ec52b4f7..e9d9dfea1 100644 --- a/NzbDrone.Core.Test/ProviderTests/JobProviderTests/JobProviderFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/JobProviderTests/JobProviderFixture.cs @@ -69,7 +69,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests [Test] public void running_scheduled_jobs_should_updates_last_execution_time() { - IList BaseFakeJobs = new List { fakeJob }; + IEnumerable BaseFakeJobs = new List { fakeJob }; Mocker.SetConstant(BaseFakeJobs); //Act @@ -86,7 +86,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests [Test] public void failing_scheduled_job_should_mark_job_as_failed() { - IList BaseFakeJobs = new List { brokenJob }; + IEnumerable BaseFakeJobs = new List { brokenJob }; Mocker.SetConstant(BaseFakeJobs); //Act @@ -105,7 +105,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests [Test] public void scheduler_skips_jobs_that_arent_mature_yet() { - IList BaseFakeJobs = new List { fakeJob }; + IEnumerable BaseFakeJobs = new List { fakeJob }; Mocker.SetConstant(BaseFakeJobs); //Act @@ -126,7 +126,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests //after execution so the job can successfully run. public void can_run_async_job_again() { - IList BaseFakeJobs = new List { fakeJob }; + IEnumerable BaseFakeJobs = new List { fakeJob }; Mocker.SetConstant(BaseFakeJobs); var jobProvider = Mocker.Resolve(); @@ -146,7 +146,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests [Test] public void no_concurent_jobs() { - IList BaseFakeJobs = new List { slowJob }; + IEnumerable BaseFakeJobs = new List { slowJob }; Mocker.SetConstant(BaseFakeJobs); var jobProvider = Mocker.Resolve(); @@ -166,7 +166,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests [Test] public void can_run_broken_job_again() { - IList BaseFakeJobs = new List { brokenJob }; + IEnumerable BaseFakeJobs = new List { brokenJob }; Mocker.SetConstant(BaseFakeJobs); @@ -188,7 +188,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests [Test] public void schedule_hit_should_be_ignored_if_queue_is_running() { - IList fakeJobs = new List { slowJob, fakeJob }; + IEnumerable fakeJobs = new List { slowJob, fakeJob }; Mocker.SetConstant(fakeJobs); @@ -210,8 +210,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests [Test] public void can_queue_jobs_at_the_same_time() { - - IList BaseFakeJobs = new List { slowJob, fakeJob }; + IEnumerable BaseFakeJobs = new List { slowJob, fakeJob }; Mocker.SetConstant(BaseFakeJobs); var jobProvider = Mocker.Resolve(); @@ -238,7 +237,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests [Test] public void Init_Jobs() { - IList BaseFakeJobs = new List { fakeJob }; + IEnumerable BaseFakeJobs = new List { fakeJob }; Mocker.SetConstant(BaseFakeJobs); @@ -265,7 +264,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests for (int i = 0; i < 2; i++) { var fakeTimer = new FakeJob(); - IList BaseFakeJobs = new List { fakeTimer }; + IEnumerable BaseFakeJobs = new List { fakeTimer }; Mocker.SetConstant(BaseFakeJobs); @@ -287,7 +286,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests [Test] public void inti_should_removed_jobs_that_no_longer_exist() { - IList fakeJobs = new List { fakeJob }; + IEnumerable fakeJobs = new List { fakeJob }; Mocker.SetConstant(fakeJobs); WithRealDb(); @@ -307,7 +306,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests [Test] public void inti_should_removed_jobs_that_no_longer_exist_even_with_same_name() { - IList fakeJobs = new List { fakeJob }; + IEnumerable fakeJobs = new List { fakeJob }; Mocker.SetConstant(fakeJobs); WithRealDb(); @@ -329,7 +328,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests [Test] public void init_should_update_existing_job() { - IList fakeJobs = new List { fakeJob }; + IEnumerable fakeJobs = new List { fakeJob }; Mocker.SetConstant(fakeJobs); WithRealDb(); @@ -364,7 +363,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests [Test] public void jobs_with_zero_interval_are_registered_as_disabled() { - IList fakeJobs = new List { disabledJob }; + IEnumerable fakeJobs = new List { disabledJob }; Mocker.SetConstant(fakeJobs); var jobProvider = Mocker.Resolve(); @@ -378,7 +377,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests [Test] public void disabled_jobs_arent_run_by_scheduler() { - IList BaseFakeJobs = new List { disabledJob }; + IEnumerable BaseFakeJobs = new List { disabledJob }; Mocker.SetConstant(BaseFakeJobs); var jobProvider = Mocker.Resolve(); @@ -394,7 +393,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests [Test] public void job_with_specific_target_should_not_update_last_execution() { - IList BaseFakeJobs = new List { fakeJob }; + IEnumerable BaseFakeJobs = new List { fakeJob }; Mocker.SetConstant(BaseFakeJobs); //Act @@ -412,7 +411,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests [Test] public void job_with_specific_target_should_not_set_success_flag() { - IList BaseFakeJobs = new List { fakeJob }; + IEnumerable BaseFakeJobs = new List { fakeJob }; Mocker.SetConstant(BaseFakeJobs); //Act @@ -430,7 +429,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests [Test] public void duplicated_queue_item_should_start_queue_if_its_not_running() { - IList BaseFakeJobs = new List { fakeJob }; + IEnumerable BaseFakeJobs = new List { fakeJob }; Mocker.SetConstant(BaseFakeJobs); var stuckQueueItem = new JobQueueItem @@ -456,7 +455,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests [Test] public void Item_added_to_queue_while_scheduler_runs_should_be_executed() { - IList BaseFakeJobs = new List { slowJob, disabledJob }; + IEnumerable BaseFakeJobs = new List { slowJob, disabledJob }; Mocker.SetConstant(BaseFakeJobs); ResetLastExecution(); @@ -477,7 +476,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests [Test] public void trygin_to_queue_unregistered_job_should_fail() { - IList BaseFakeJobs = new List { slowJob, disabledJob }; + IEnumerable BaseFakeJobs = new List { slowJob, disabledJob }; Mocker.SetConstant(BaseFakeJobs); var jobProvider = Mocker.Resolve(); @@ -492,7 +491,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests [Test] public void scheduled_job_should_have_scheduler_as_source() { - IList BaseFakeJobs = new List { slowJob, fakeJob}; + IEnumerable BaseFakeJobs = new List { slowJob, fakeJob}; Mocker.SetConstant(BaseFakeJobs); var jobProvider = Mocker.Resolve(); @@ -504,8 +503,5 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests WaitForQueue(); } - } - - } diff --git a/NzbDrone.Core.Test/ProviderTests/TvDbProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/TvDbProviderTest.cs index 9f792ed68..a813722fa 100644 --- a/NzbDrone.Core.Test/ProviderTests/TvDbProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/TvDbProviderTest.cs @@ -3,9 +3,9 @@ using System; using System.Collections.Generic; using System.Linq; +using Autofac; using FluentAssertions; using NUnit.Framework; -using Ninject; using NzbDrone.Common; using NzbDrone.Core.Providers; using NzbDrone.Core.Test.Framework; @@ -24,7 +24,14 @@ namespace NzbDrone.Core.Test.ProviderTests [SetUp] public void Setup() { - tvDbProvider = new StandardKernel().Get(); + var builder = new ContainerBuilder(); + + builder.RegisterType(); + builder.RegisterType(); + + var container = builder.Build(); + + tvDbProvider = container.Resolve(); } [TearDown] diff --git a/NzbDrone.Core.Test/ProviderTests/TvRageProviderTests/GetSeriesFixture.cs b/NzbDrone.Core.Test/ProviderTests/TvRageProviderTests/GetSeriesFixture.cs index d5adac66a..e905a0aea 100644 --- a/NzbDrone.Core.Test/ProviderTests/TvRageProviderTests/GetSeriesFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/TvRageProviderTests/GetSeriesFixture.cs @@ -7,7 +7,6 @@ using System.Linq; using FluentAssertions; using Moq; using NUnit.Framework; -using Ninject; using NzbDrone.Common; using NzbDrone.Core.Providers; using NzbDrone.Core.Test.Framework; diff --git a/NzbDrone.Core.Test/ProviderTests/TvRageProviderTests/GetUtcOffsetFixture.cs b/NzbDrone.Core.Test/ProviderTests/TvRageProviderTests/GetUtcOffsetFixture.cs index 8c55feaef..aabaee44d 100644 --- a/NzbDrone.Core.Test/ProviderTests/TvRageProviderTests/GetUtcOffsetFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/TvRageProviderTests/GetUtcOffsetFixture.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Linq; using FluentAssertions; using NUnit.Framework; -using Ninject; using NzbDrone.Common; using NzbDrone.Core.Providers; using NzbDrone.Core.Test.Framework; diff --git a/NzbDrone.Core.Test/ProviderTests/TvRageProviderTests/SearchSeriesFixture.cs b/NzbDrone.Core.Test/ProviderTests/TvRageProviderTests/SearchSeriesFixture.cs index 1d64de299..572a86237 100644 --- a/NzbDrone.Core.Test/ProviderTests/TvRageProviderTests/SearchSeriesFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/TvRageProviderTests/SearchSeriesFixture.cs @@ -7,7 +7,6 @@ using System.Linq; using FluentAssertions; using Moq; using NUnit.Framework; -using Ninject; using NzbDrone.Common; using NzbDrone.Core.Providers; using NzbDrone.Core.Test.Framework; diff --git a/NzbDrone.Core.Test/packages.config b/NzbDrone.Core.Test/packages.config index 2058375ef..2bdc043fe 100644 --- a/NzbDrone.Core.Test/packages.config +++ b/NzbDrone.Core.Test/packages.config @@ -1,5 +1,6 @@  + @@ -10,7 +11,6 @@ - diff --git a/NzbDrone.Core/AutofacSignalrDependencyResolver.cs b/NzbDrone.Core/AutofacSignalrDependencyResolver.cs new file mode 100644 index 000000000..600fe0f4d --- /dev/null +++ b/NzbDrone.Core/AutofacSignalrDependencyResolver.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Autofac; +using Autofac.Builder; +using Autofac.Core; +using SignalR; + +namespace NzbDrone.Core +{ + public class AutofacSignalrDependencyResolver : DefaultDependencyResolver, IDependencyResolver, IRegistrationSource + { + private ILifetimeScope LifetimeScope { get; set; } + + public AutofacSignalrDependencyResolver(ILifetimeScope lifetimeScope) + { + LifetimeScope = lifetimeScope; + var currentRegistrationSource = + LifetimeScope.ComponentRegistry.Sources.FirstOrDefault(s => s.GetType() == GetType()); + if (currentRegistrationSource != null) + { + ((AutofacSignalrDependencyResolver)currentRegistrationSource).LifetimeScope = lifetimeScope; + } + else + { + LifetimeScope.ComponentRegistry.AddRegistrationSource(this); + } + } + + public AutofacSignalrDependencyResolver() + { + } + + public override object GetService(Type serviceType) + { + object result; + + if (LifetimeScope == null) + { + return base.GetService(serviceType); + } + + if (LifetimeScope.TryResolve(serviceType, out result)) + { + return result; + } + + return null; + } + + public override IEnumerable GetServices(Type serviceType) + { + object result; + + if (LifetimeScope == null) + { + return base.GetServices(serviceType); + } + + if (LifetimeScope.TryResolve(typeof(IEnumerable<>).MakeGenericType(serviceType), out result)) + { + return (IEnumerable)result; + } + + return Enumerable.Empty(); + } + + public IEnumerable RegistrationsFor(Service service, Func> registrationAccessor) + { + var typedService = service as TypedService; + if (typedService != null) + { + var instances = base.GetServices(typedService.ServiceType); + + if (instances != null) + { + return instances + .Select(i => RegistrationBuilder.ForDelegate(i.GetType(), (c, p) => i).As(typedService.ServiceType) + .InstancePerLifetimeScope() + .PreserveExistingDefaults() + .CreateRegistration()); + } + } + + return Enumerable.Empty(); + } + + bool IRegistrationSource.IsAdapterForIndividualComponents + { + get { return false; } + } + } +} diff --git a/NzbDrone.Core/CentralDispatch.cs b/NzbDrone.Core/CentralDispatch.cs index 63448a040..078f0f577 100644 --- a/NzbDrone.Core/CentralDispatch.cs +++ b/NzbDrone.Core/CentralDispatch.cs @@ -3,8 +3,10 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; +using System.Reflection; +using Autofac; +using Autofac.Core; using DeskMetrics; -using Ninject; using NLog; using NzbDrone.Common; using NzbDrone.Core.Instrumentation; @@ -29,140 +31,113 @@ namespace NzbDrone.Core private static readonly Logger logger = LogManager.GetCurrentClassLogger(); private readonly EnvironmentProvider _environmentProvider; - public StandardKernel Kernel { get; private set; } + public ContainerBuilder ContainerBuilder { get; private set; } public CentralDispatch() { _environmentProvider = new EnvironmentProvider(); - logger.Debug("Initializing Kernel:"); - Kernel = new StandardKernel(); + logger.Debug("Initializing ContainerBuilder:"); + ContainerBuilder = new ContainerBuilder(); - GlobalHost.DependencyResolver = new NinjectDependencyResolver(Kernel); + ContainerBuilder.RegisterAssemblyTypes(typeof(DiskProvider).Assembly).SingleInstance(); + ContainerBuilder.RegisterAssemblyTypes(typeof(CentralDispatch).Assembly).SingleInstance(); + ContainerBuilder.RegisterType(); InitDatabase(); - InitReporting(); - - InitQuality(); InitExternalNotifications(); InitMetadataProviders(); InitIndexers(); - InitJobs(); + RegisterJobs(); } private void InitDatabase() { - logger.Info("Initializing Database..."); + logger.Info("Registering Database..."); var appDataPath = _environmentProvider.GetAppDataPath(); if (!Directory.Exists(appDataPath)) Directory.CreateDirectory(appDataPath); - var connection = Kernel.Get(); - Kernel.Bind().ToMethod(c => connection.GetMainPetaPocoDb()).InTransientScope(); - Kernel.Bind().ToMethod(c => connection.GetLogPetaPocoDb(false)).WhenInjectedInto().InSingletonScope(); - Kernel.Bind().ToMethod(c => connection.GetLogPetaPocoDb()).WhenInjectedInto(); - Kernel.Bind().ToMethod(c => connection.GetLogEfContext()).WhenInjectedInto().InSingletonScope(); + ContainerBuilder.Register(c => c.Resolve().GetMainPetaPocoDb()) + .As(); - Kernel.Get().Register(); - LogConfiguration.Reload(); - } + ContainerBuilder.Register(c => c.Resolve().GetLogPetaPocoDb(false)) + .SingleInstance() + .Named("DatabaseTarget"); - private void InitReporting() - { - EnvironmentProvider.UGuid = Kernel.Get().UGuid; - ReportingService.RestProvider = Kernel.Get(); - ReportingService.SetupExceptronDriver(); + ContainerBuilder.Register(c => c.Resolve().GetLogPetaPocoDb()) + .Named("LogProvider"); + + ContainerBuilder.Register(c => c.Resolve().GetLogEfContext()) + .As() + .SingleInstance(); + + ContainerBuilder.RegisterType().WithParameter(ResolvedParameter.ForNamed("DatabaseTarget")); + ContainerBuilder.RegisterType().WithParameter(ResolvedParameter.ForNamed("LogProvider")); } - private void InitQuality() + private void InitIndexers() { - logger.Debug("Initializing Quality..."); - Kernel.Get().SetupDefaultProfiles(); - Kernel.Get().SetupDefault(); + logger.Debug("Registering Indexers..."); + + ContainerBuilder.RegisterAssemblyTypes(typeof(CentralDispatch).Assembly) + .Where(t => t.BaseType == typeof(IndexerBase)) + .As(); + + //ContainerBuilder.Bind().To(); + //ContainerBuilder.Bind().To(); + //ContainerBuilder.Bind().To(); + //ContainerBuilder.Bind().To(); + //ContainerBuilder.Bind().To(); + //ContainerBuilder.Bind().To(); + //ContainerBuilder.Bind().To(); + //ContainerBuilder.Bind().To(); } - private void InitIndexers() + private void RegisterJobs() { - logger.Debug("Initializing Indexers..."); - Kernel.Bind().To(); - Kernel.Bind().To(); - Kernel.Bind().To(); - Kernel.Bind().To(); - Kernel.Bind().To(); - Kernel.Bind().To(); - Kernel.Bind().To(); - Kernel.Bind().To(); - - var indexers = Kernel.GetAll(); - Kernel.Get().InitializeIndexers(indexers.ToList()); + logger.Debug("Registering Background Jobs..."); - var newznabIndexers = new List - { - new NewznabDefinition { Enable = false, Name = "Nzbs.org", Url = "http://nzbs.org", BuiltIn = true }, - new NewznabDefinition { Enable = false, Name = "Nzb.su", Url = "https://nzb.su", BuiltIn = true }, - new NewznabDefinition { Enable = false, Name = "Dognzb.cr", Url = "https://dognzb.cr", BuiltIn = true } - }; + ContainerBuilder.RegisterType().SingleInstance(); - Kernel.Get().InitializeNewznabIndexers(newznabIndexers); - } + ContainerBuilder.RegisterType().As().SingleInstance(); - private void InitJobs() - { - logger.Debug("Initializing Background Jobs..."); - - Kernel.Bind().ToSelf().InSingletonScope(); - - Kernel.Bind().To().InSingletonScope(); - Kernel.Bind().To().InSingletonScope(); - Kernel.Bind().To().InSingletonScope(); - Kernel.Bind().To().InSingletonScope(); - Kernel.Bind().To().InSingletonScope(); - Kernel.Bind().To().InSingletonScope(); - Kernel.Bind().To().InSingletonScope(); - Kernel.Bind().To().InSingletonScope(); - Kernel.Bind().To().InSingletonScope(); - Kernel.Bind().To().InSingletonScope(); - Kernel.Bind().To().InSingletonScope(); - Kernel.Bind().To().InSingletonScope(); - Kernel.Bind().To().InSingletonScope(); - Kernel.Bind().To().InSingletonScope(); - Kernel.Bind().To().InSingletonScope(); - Kernel.Bind().To().InSingletonScope(); - Kernel.Bind().To().InSingletonScope(); - Kernel.Bind().To().InSingletonScope(); - Kernel.Bind().To().InSingletonScope(); - Kernel.Bind().To().InSingletonScope(); - Kernel.Bind().To().InSingletonScope(); - Kernel.Bind().To().InSingletonScope(); - Kernel.Bind().To().InSingletonScope(); - Kernel.Bind().To().InSingletonScope(); - - Kernel.Get().Initialize(); - Kernel.Get().StartTimer(30); + ContainerBuilder.RegisterAssemblyTypes(typeof(CentralDispatch).Assembly) + .Where(t => t.GetInterfaces().Contains(typeof(IJob))) + .As() + .SingleInstance(); } private void InitExternalNotifications() { - logger.Debug("Initializing External Notifications..."); - Kernel.Bind().To(); - Kernel.Bind().To(); - Kernel.Bind().To(); - Kernel.Bind().To(); - Kernel.Bind().To(); - Kernel.Bind().To(); - - var notifiers = Kernel.GetAll(); - Kernel.Get().InitializeNotifiers(notifiers.ToList()); + logger.Debug("Registering External Notifications..."); + ContainerBuilder.RegisterType().As().SingleInstance(); + ContainerBuilder.RegisterType().As().SingleInstance(); + ContainerBuilder.RegisterType().As().SingleInstance(); + ContainerBuilder.RegisterType().As().SingleInstance(); + ContainerBuilder.RegisterType().As().SingleInstance(); + ContainerBuilder.RegisterType().As().SingleInstance(); } private void InitMetadataProviders() { - logger.Debug("Initializing Metadata Providers..."); + logger.Debug("Registering Metadata Providers..."); - Kernel.Bind().To().InSingletonScope(); + ContainerBuilder.RegisterType().As().SingleInstance(); + } + + private void InitReporting(IContainer container) + { + EnvironmentProvider.UGuid = container.Resolve().UGuid; + ReportingService.RestProvider = container.Resolve(); + ReportingService.SetupExceptronDriver(); + } - var providers = Kernel.GetAll(); - Kernel.Get().Initialize(providers.ToList()); + private void InitQuality(IContainer container) + { + logger.Debug("Initializing Quality..."); + container.Resolve().SetupDefaultProfiles(); + container.Resolve().SetupDefault(); } public void DedicateToHost() @@ -190,6 +165,45 @@ namespace NzbDrone.Core } } + public IContainer Build() + { + var container = ContainerBuilder.Build(); + + logger.Debug("Initializing Components"); + + container.Resolve().Register(); + LogConfiguration.Reload(); + + InitReporting(container); + InitQuality(container); + + var indexers = container.Resolve>(); + container.Resolve().InitializeIndexers(indexers.ToList()); + + var newznabIndexers = new List + { + new NewznabDefinition { Enable = false, Name = "Nzbs.org", Url = "http://nzbs.org", BuiltIn = true }, + new NewznabDefinition { Enable = false, Name = "Nzb.su", Url = "https://nzb.su", BuiltIn = true }, + new NewznabDefinition { Enable = false, Name = "Dognzb.cr", Url = "https://dognzb.cr", BuiltIn = true } + }; + + container.Resolve().InitializeNewznabIndexers(newznabIndexers); + + container.Resolve().Initialize(); + container.Resolve().StartTimer(30); + + var notifiers = container.Resolve>(); + container.Resolve().InitializeNotifiers(notifiers.ToList()); + + var providers = container.Resolve>(); + container.Resolve().Initialize(providers.ToList()); + + //SignalR + GlobalHost.DependencyResolver = new AutofacSignalrDependencyResolver(container.BeginLifetimeScope("SignalR")); + + return container; + } + private static void ShutDown() { logger.Info("Shutting down application..."); diff --git a/NzbDrone.Core/Instrumentation/DatabaseTarget.cs b/NzbDrone.Core/Instrumentation/DatabaseTarget.cs index 2e895825b..b4160565c 100644 --- a/NzbDrone.Core/Instrumentation/DatabaseTarget.cs +++ b/NzbDrone.Core/Instrumentation/DatabaseTarget.cs @@ -1,6 +1,5 @@ using System; using NLog.Config; -using Ninject; using NLog; using NLog.Targets; using NLog.Targets.Wrappers; @@ -14,7 +13,6 @@ namespace NzbDrone.Core.Instrumentation { private readonly IDatabase _database; - [Inject] public DatabaseTarget(IDatabase database) { _database = database; diff --git a/NzbDrone.Core/Instrumentation/LogDbContext.cs b/NzbDrone.Core/Instrumentation/LogDbContext.cs index d31965884..e8d21a2d3 100644 --- a/NzbDrone.Core/Instrumentation/LogDbContext.cs +++ b/NzbDrone.Core/Instrumentation/LogDbContext.cs @@ -1,13 +1,11 @@ using System.Data.Common; using System.Data.Entity; using System.Linq; -using Ninject; namespace NzbDrone.Core.Instrumentation { public class LogDbContext : DbContext { - [Inject] public LogDbContext(DbConnection connection) : base(connection, false) { diff --git a/NzbDrone.Core/Jobs/AppUpdateJob.cs b/NzbDrone.Core/Jobs/AppUpdateJob.cs index 1389b68b1..c4512d373 100644 --- a/NzbDrone.Core/Jobs/AppUpdateJob.cs +++ b/NzbDrone.Core/Jobs/AppUpdateJob.cs @@ -3,7 +3,6 @@ using System.Linq; using System.Diagnostics; using System.IO; using NLog; -using Ninject; using NzbDrone.Common; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; @@ -23,7 +22,6 @@ namespace NzbDrone.Core.Jobs private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - [Inject] public AppUpdateJob(UpdateProvider updateProvider, EnvironmentProvider environmentProvider, DiskProvider diskProvider, HttpProvider httpProvider, ProcessProvider processProvider, ArchiveProvider archiveProvider, ConfigFileProvider configFileProvider) { diff --git a/NzbDrone.Core/Jobs/BacklogSearchJob.cs b/NzbDrone.Core/Jobs/BacklogSearchJob.cs index 3699b4c3c..df682f99d 100644 --- a/NzbDrone.Core/Jobs/BacklogSearchJob.cs +++ b/NzbDrone.Core/Jobs/BacklogSearchJob.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using NLog; -using Ninject; using NzbDrone.Core.Model; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; @@ -20,7 +19,6 @@ namespace NzbDrone.Core.Jobs private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - [Inject] public BacklogSearchJob(EpisodeProvider episodeProvider, EpisodeSearchJob episodeSearchJob, SeasonSearchJob seasonSearchJob, ConfigProvider configProvider) { diff --git a/NzbDrone.Core/Jobs/BannerDownloadJob.cs b/NzbDrone.Core/Jobs/BannerDownloadJob.cs index 8ab075077..e442c4861 100644 --- a/NzbDrone.Core/Jobs/BannerDownloadJob.cs +++ b/NzbDrone.Core/Jobs/BannerDownloadJob.cs @@ -1,7 +1,6 @@ using System; using System.IO; using System.Linq; -using Ninject; using NLog; using NzbDrone.Common; using NzbDrone.Core.Model.Notification; @@ -19,7 +18,6 @@ namespace NzbDrone.Core.Jobs private const string BANNER_URL_PREFIX = "http://www.thetvdb.com/banners/"; - [Inject] public BannerDownloadJob(SeriesProvider seriesProvider, BannerProvider bannerProvider) { _seriesProvider = seriesProvider; diff --git a/NzbDrone.Core/Jobs/CleanupRecycleBinJob.cs b/NzbDrone.Core/Jobs/CleanupRecycleBinJob.cs index 2f28ade7d..6c8ea00fe 100644 --- a/NzbDrone.Core/Jobs/CleanupRecycleBinJob.cs +++ b/NzbDrone.Core/Jobs/CleanupRecycleBinJob.cs @@ -1,6 +1,5 @@ using System.Linq; using System; -using Ninject; using NLog; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; @@ -12,7 +11,6 @@ namespace NzbDrone.Core.Jobs { private readonly RecycleBinProvider _recycleBinProvider; - [Inject] public CleanupRecycleBinJob(RecycleBinProvider recycleBinProvider) { _recycleBinProvider = recycleBinProvider; diff --git a/NzbDrone.Core/Jobs/ConvertEpisodeJob.cs b/NzbDrone.Core/Jobs/ConvertEpisodeJob.cs index 5501dbd6b..df450ae9d 100644 --- a/NzbDrone.Core/Jobs/ConvertEpisodeJob.cs +++ b/NzbDrone.Core/Jobs/ConvertEpisodeJob.cs @@ -1,6 +1,5 @@ using System.Linq; using System; -using Ninject; using NLog; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; @@ -17,7 +16,6 @@ namespace NzbDrone.Core.Jobs private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - [Inject] public ConvertEpisodeJob(HandbrakeProvider handbrakeProvider, AtomicParsleyProvider atomicParsleyProvider, EpisodeProvider episodeProvider) { diff --git a/NzbDrone.Core/Jobs/DeleteSeriesJob.cs b/NzbDrone.Core/Jobs/DeleteSeriesJob.cs index 07b79b6a9..376670950 100644 --- a/NzbDrone.Core/Jobs/DeleteSeriesJob.cs +++ b/NzbDrone.Core/Jobs/DeleteSeriesJob.cs @@ -1,6 +1,5 @@ using System.Linq; using System; -using Ninject; using NLog; using NzbDrone.Common; using NzbDrone.Core.Model.Notification; @@ -15,7 +14,6 @@ namespace NzbDrone.Core.Jobs private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - [Inject] public DeleteSeriesJob(SeriesProvider seriesProvider, RecycleBinProvider recycleBinProvider) { _seriesProvider = seriesProvider; diff --git a/NzbDrone.Core/Jobs/DiskScanJob.cs b/NzbDrone.Core/Jobs/DiskScanJob.cs index 7100f7bb1..6429a1e2e 100644 --- a/NzbDrone.Core/Jobs/DiskScanJob.cs +++ b/NzbDrone.Core/Jobs/DiskScanJob.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using Ninject; using NLog; using NzbDrone.Core.Helpers; using NzbDrone.Core.Model.Notification; @@ -18,7 +17,6 @@ namespace NzbDrone.Core.Jobs private readonly ConfigProvider _configProvider; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - [Inject] public DiskScanJob(SeriesProvider seriesProvider, DiskScanProvider diskScanProvider, ConfigProvider configProvider) { diff --git a/NzbDrone.Core/Jobs/EmptyRecycleBinJob.cs b/NzbDrone.Core/Jobs/EmptyRecycleBinJob.cs index 7133b4080..9d586993e 100644 --- a/NzbDrone.Core/Jobs/EmptyRecycleBinJob.cs +++ b/NzbDrone.Core/Jobs/EmptyRecycleBinJob.cs @@ -1,6 +1,5 @@ using System.Linq; using System; -using Ninject; using NLog; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; @@ -12,7 +11,6 @@ namespace NzbDrone.Core.Jobs { private readonly RecycleBinProvider _recycleBinProvider; - [Inject] public EmptyRecycleBinJob(RecycleBinProvider recycleBinProvider) { _recycleBinProvider = recycleBinProvider; diff --git a/NzbDrone.Core/Jobs/EpisodeSearchJob.cs b/NzbDrone.Core/Jobs/EpisodeSearchJob.cs index 0eeb50dcf..8a28b2edf 100644 --- a/NzbDrone.Core/Jobs/EpisodeSearchJob.cs +++ b/NzbDrone.Core/Jobs/EpisodeSearchJob.cs @@ -1,6 +1,5 @@ using System.Linq; using System; -using Ninject; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; @@ -10,7 +9,6 @@ namespace NzbDrone.Core.Jobs { private readonly SearchProvider _searchProvider; - [Inject] public EpisodeSearchJob(SearchProvider searchProvider) { _searchProvider = searchProvider; diff --git a/NzbDrone.Core/Jobs/ImportNewSeriesJob.cs b/NzbDrone.Core/Jobs/ImportNewSeriesJob.cs index 44d1c5d07..314b76d5f 100644 --- a/NzbDrone.Core/Jobs/ImportNewSeriesJob.cs +++ b/NzbDrone.Core/Jobs/ImportNewSeriesJob.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using Ninject; using NLog; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; @@ -28,7 +27,6 @@ namespace NzbDrone.Core.Jobs private List _attemptedSeries; - [Inject] public ImportNewSeriesJob(SeriesProvider seriesProvider, EpisodeProvider episodeProvider, MediaFileProvider mediaFileProvider, UpdateInfoJob updateInfoJob, DiskScanJob diskScanJob, BannerDownloadJob bannerDownloadJob, diff --git a/NzbDrone.Core/Jobs/JobProvider.cs b/NzbDrone.Core/Jobs/JobProvider.cs index da3e1ce0c..8641e5d2c 100644 --- a/NzbDrone.Core/Jobs/JobProvider.cs +++ b/NzbDrone.Core/Jobs/JobProvider.cs @@ -7,7 +7,6 @@ using System.Diagnostics; using System.Linq; using System.Threading; using NLog; -using Ninject; using NzbDrone.Core.Model; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; @@ -25,7 +24,7 @@ namespace NzbDrone.Core.Jobs private static readonly Logger logger = LogManager.GetCurrentClassLogger(); private readonly IDatabase _database; private readonly NotificationProvider _notificationProvider; - private readonly IList _jobs; + private readonly IEnumerable _jobs; private Thread _jobThread; public Stopwatch StopWatch { get; private set; } @@ -36,8 +35,7 @@ namespace NzbDrone.Core.Jobs private ProgressNotification _notification; - [Inject] - public JobProvider(IDatabase database, NotificationProvider notificationProvider, IList jobs) + public JobProvider(IDatabase database, NotificationProvider notificationProvider, IEnumerable jobs) { StopWatch = new Stopwatch(); _database = database; diff --git a/NzbDrone.Core/Jobs/PastWeekBacklogSearchJob.cs b/NzbDrone.Core/Jobs/PastWeekBacklogSearchJob.cs index 668b02f78..87d6b92e5 100644 --- a/NzbDrone.Core/Jobs/PastWeekBacklogSearchJob.cs +++ b/NzbDrone.Core/Jobs/PastWeekBacklogSearchJob.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using NLog; -using Ninject; using NzbDrone.Core.Model; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; @@ -19,7 +18,6 @@ namespace NzbDrone.Core.Jobs private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - [Inject] public PastWeekBacklogSearchJob(EpisodeProvider episodeProvider, EpisodeSearchJob episodeSearchJob, ConfigProvider configProvider) { diff --git a/NzbDrone.Core/Jobs/PostDownloadScanJob.cs b/NzbDrone.Core/Jobs/PostDownloadScanJob.cs index 57aa13f76..bbaf7e54d 100644 --- a/NzbDrone.Core/Jobs/PostDownloadScanJob.cs +++ b/NzbDrone.Core/Jobs/PostDownloadScanJob.cs @@ -1,7 +1,6 @@ using System.Linq; using System; using NLog; -using Ninject; using NzbDrone.Common; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; @@ -17,7 +16,6 @@ namespace NzbDrone.Core.Jobs private readonly ConfigProvider _configProvider; private readonly DiskProvider _diskProvider; - [Inject] public PostDownloadScanJob(PostDownloadProvider postDownloadProvider,ConfigProvider configProvider, DiskProvider diskProvider) { _postDownloadProvider = postDownloadProvider; diff --git a/NzbDrone.Core/Jobs/RecentBacklogSearchJob.cs b/NzbDrone.Core/Jobs/RecentBacklogSearchJob.cs index 153f5c364..4e0333531 100644 --- a/NzbDrone.Core/Jobs/RecentBacklogSearchJob.cs +++ b/NzbDrone.Core/Jobs/RecentBacklogSearchJob.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using NLog; -using Ninject; using NzbDrone.Core.Model; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; @@ -19,7 +18,6 @@ namespace NzbDrone.Core.Jobs private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - [Inject] public RecentBacklogSearchJob(EpisodeProvider episodeProvider, EpisodeSearchJob episodeSearchJob, ConfigProvider configProvider) { diff --git a/NzbDrone.Core/Jobs/RefreshEpsiodeMetadata.cs b/NzbDrone.Core/Jobs/RefreshEpsiodeMetadata.cs index 7cd38bae1..55a55a6c5 100644 --- a/NzbDrone.Core/Jobs/RefreshEpsiodeMetadata.cs +++ b/NzbDrone.Core/Jobs/RefreshEpsiodeMetadata.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System; using NLog; -using Ninject; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; using NzbDrone.Core.Repository; @@ -17,7 +16,6 @@ namespace NzbDrone.Core.Jobs private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - [Inject] public RefreshEpisodeMetadata(MediaFileProvider mediaFileProvider, SeriesProvider seriesProvider, MetadataProvider metadataProvider) { diff --git a/NzbDrone.Core/Jobs/RenameSeasonJob.cs b/NzbDrone.Core/Jobs/RenameSeasonJob.cs index de771c24f..513b9eee2 100644 --- a/NzbDrone.Core/Jobs/RenameSeasonJob.cs +++ b/NzbDrone.Core/Jobs/RenameSeasonJob.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System; using NLog; -using Ninject; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; using NzbDrone.Core.Repository; @@ -19,7 +18,6 @@ namespace NzbDrone.Core.Jobs private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - [Inject] public RenameSeasonJob(MediaFileProvider mediaFileProvider, DiskScanProvider diskScanProvider, ExternalNotificationProvider externalNotificationProvider, SeriesProvider seriesProvider, MetadataProvider metadataProvider) diff --git a/NzbDrone.Core/Jobs/RenameSeriesJob.cs b/NzbDrone.Core/Jobs/RenameSeriesJob.cs index 171ccf363..ebb3bcbdf 100644 --- a/NzbDrone.Core/Jobs/RenameSeriesJob.cs +++ b/NzbDrone.Core/Jobs/RenameSeriesJob.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System; using NLog; -using Ninject; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; using NzbDrone.Core.Repository; @@ -19,7 +18,6 @@ namespace NzbDrone.Core.Jobs private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - [Inject] public RenameSeriesJob(MediaFileProvider mediaFileProvider, DiskScanProvider diskScanProvider, ExternalNotificationProvider externalNotificationProvider, SeriesProvider seriesProvider, MetadataProvider metadataProvider) diff --git a/NzbDrone.Core/Jobs/RssSyncJob.cs b/NzbDrone.Core/Jobs/RssSyncJob.cs index 59a6eac9a..57a788c4d 100644 --- a/NzbDrone.Core/Jobs/RssSyncJob.cs +++ b/NzbDrone.Core/Jobs/RssSyncJob.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Ninject; using NLog; using NzbDrone.Core.Model; using NzbDrone.Core.Model.Notification; @@ -26,7 +25,6 @@ namespace NzbDrone.Core.Jobs private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - [Inject] public RssSyncJob(DownloadProvider downloadProvider, IndexerProvider indexerProvider, MonitoredEpisodeSpecification isMonitoredEpisodeSpecification, AllowedDownloadSpecification allowedDownloadSpecification, UpgradeHistorySpecification upgradeHistorySpecification, ConfigProvider configProvider) diff --git a/NzbDrone.Core/Jobs/SearchHistoryCleanupJob.cs b/NzbDrone.Core/Jobs/SearchHistoryCleanupJob.cs index 797afb7aa..8802c9ba1 100644 --- a/NzbDrone.Core/Jobs/SearchHistoryCleanupJob.cs +++ b/NzbDrone.Core/Jobs/SearchHistoryCleanupJob.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using Ninject; using NLog; using NzbDrone.Core.Helpers; using NzbDrone.Core.Model.Notification; @@ -16,7 +15,6 @@ namespace NzbDrone.Core.Jobs private readonly SearchHistoryProvider _searchHistoryProvider; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - [Inject] public SearchHistoryCleanupJob(SearchHistoryProvider searchHistoryProvider) { _searchHistoryProvider = searchHistoryProvider; diff --git a/NzbDrone.Core/Jobs/SeasonSearchJob.cs b/NzbDrone.Core/Jobs/SeasonSearchJob.cs index e1fd232cb..42e7391c1 100644 --- a/NzbDrone.Core/Jobs/SeasonSearchJob.cs +++ b/NzbDrone.Core/Jobs/SeasonSearchJob.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using NLog; -using Ninject; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; using NzbDrone.Core.Repository; @@ -17,7 +16,6 @@ namespace NzbDrone.Core.Jobs private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - [Inject] public SeasonSearchJob(SearchProvider searchProvider, EpisodeSearchJob episodeSearchJob, EpisodeProvider episodeProvider) { diff --git a/NzbDrone.Core/Jobs/SeriesSearchJob.cs b/NzbDrone.Core/Jobs/SeriesSearchJob.cs index aa6f648ae..53bd5b52e 100644 --- a/NzbDrone.Core/Jobs/SeriesSearchJob.cs +++ b/NzbDrone.Core/Jobs/SeriesSearchJob.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using NLog; -using Ninject; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; using NzbDrone.Core.Repository; @@ -16,7 +15,6 @@ namespace NzbDrone.Core.Jobs private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - [Inject] public SeriesSearchJob(SeasonSearchJob seasonSearchJob, SeasonProvider seasonProvider) { diff --git a/NzbDrone.Core/Jobs/TrimLogsJob.cs b/NzbDrone.Core/Jobs/TrimLogsJob.cs index 4d9395572..146e243dc 100644 --- a/NzbDrone.Core/Jobs/TrimLogsJob.cs +++ b/NzbDrone.Core/Jobs/TrimLogsJob.cs @@ -1,6 +1,5 @@ using System; using System.Linq; -using Ninject; using NzbDrone.Core.Instrumentation; using NzbDrone.Core.Model.Notification; @@ -10,7 +9,6 @@ namespace NzbDrone.Core.Jobs { private readonly LogProvider _logProvider; - [Inject] public TrimLogsJob(LogProvider logProvider) { _logProvider = logProvider; diff --git a/NzbDrone.Core/Jobs/UpdateInfoJob.cs b/NzbDrone.Core/Jobs/UpdateInfoJob.cs index f7cebf4f6..55aefd9ec 100644 --- a/NzbDrone.Core/Jobs/UpdateInfoJob.cs +++ b/NzbDrone.Core/Jobs/UpdateInfoJob.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using NLog; -using Ninject; using NzbDrone.Core.Helpers; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; @@ -19,7 +18,6 @@ namespace NzbDrone.Core.Jobs private readonly ConfigProvider _configProvider; private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - [Inject] public UpdateInfoJob(SeriesProvider seriesProvider, EpisodeProvider episodeProvider, ReferenceDataProvider referenceDataProvider, ConfigProvider configProvider) { diff --git a/NzbDrone.Core/Jobs/UpdateSceneMappingsJob.cs b/NzbDrone.Core/Jobs/UpdateSceneMappingsJob.cs index f4db29e71..85acc6329 100644 --- a/NzbDrone.Core/Jobs/UpdateSceneMappingsJob.cs +++ b/NzbDrone.Core/Jobs/UpdateSceneMappingsJob.cs @@ -1,6 +1,5 @@ using System; using System.Linq; -using Ninject; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; @@ -10,7 +9,6 @@ namespace NzbDrone.Core.Jobs { private readonly SceneMappingProvider _sceneNameMappingProvider; - [Inject] public UpdateSceneMappingsJob(SceneMappingProvider sceneNameMappingProvider) { _sceneNameMappingProvider = sceneNameMappingProvider; diff --git a/NzbDrone.Core/Jobs/XemUpdateJob.cs b/NzbDrone.Core/Jobs/XemUpdateJob.cs index 56066fec2..251884e9e 100644 --- a/NzbDrone.Core/Jobs/XemUpdateJob.cs +++ b/NzbDrone.Core/Jobs/XemUpdateJob.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using NLog; -using Ninject; using NzbDrone.Core.Helpers; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; @@ -16,7 +15,6 @@ namespace NzbDrone.Core.Jobs private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); - [Inject] public XemUpdateJob(XemProvider xemProvider) { _xemProvider = xemProvider; diff --git a/NzbDrone.Core/NinjectDependencyResolver.cs b/NzbDrone.Core/NinjectDependencyResolver.cs deleted file mode 100644 index 76bf75ba8..000000000 --- a/NzbDrone.Core/NinjectDependencyResolver.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Ninject; -using SignalR; - -namespace NzbDrone.Core -{ - public class NinjectDependencyResolver : DefaultDependencyResolver - { - private readonly IKernel _kernel; - - public NinjectDependencyResolver(IKernel kernel) - { - if (kernel == null) - { - throw new ArgumentNullException("kernel"); - } - - _kernel = kernel; - } - - public override object GetService(Type serviceType) - { - return _kernel.TryGet(serviceType) ?? base.GetService(serviceType); - } - - public override IEnumerable GetServices(Type serviceType) - { - return _kernel.GetAll(serviceType).Concat(base.GetServices(serviceType)); - } - } -} diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 8b7f2182f..86585874a 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -123,6 +123,12 @@ + + ..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.dll + + + ..\packages\Autofac.2.6.3.862\lib\NET40\Autofac.Configuration.dll + False ..\packages\DataTables.Mvc.Core.0.1.0.85\lib\DataTables.Mvc.Core.dll @@ -167,10 +173,6 @@ False ..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll - - False - ..\packages\Ninject.3.0.1.10\lib\net40\Ninject.dll - ..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll @@ -316,7 +318,7 @@ - + diff --git a/NzbDrone.Core/Providers/BackupProvider.cs b/NzbDrone.Core/Providers/BackupProvider.cs index d7fb83f40..5fad7a641 100644 --- a/NzbDrone.Core/Providers/BackupProvider.cs +++ b/NzbDrone.Core/Providers/BackupProvider.cs @@ -2,7 +2,6 @@ using System.Linq; using Ionic.Zip; using NLog; -using Ninject; using NzbDrone.Common; namespace NzbDrone.Core.Providers @@ -12,7 +11,6 @@ namespace NzbDrone.Core.Providers private readonly EnvironmentProvider _environmentProvider; private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - [Inject] public BackupProvider(EnvironmentProvider environmentProvider) { _environmentProvider = environmentProvider; diff --git a/NzbDrone.Core/Providers/BannerProvider.cs b/NzbDrone.Core/Providers/BannerProvider.cs index 16f091a43..c9961abe0 100644 --- a/NzbDrone.Core/Providers/BannerProvider.cs +++ b/NzbDrone.Core/Providers/BannerProvider.cs @@ -4,7 +4,6 @@ using System.IO; using System.Linq; using System.Text; using NLog; -using Ninject; using NzbDrone.Common; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Repository; @@ -20,7 +19,6 @@ namespace NzbDrone.Core.Providers private const string BANNER_URL_PREFIX = "http://www.thetvdb.com/banners/"; - [Inject] public BannerProvider(HttpProvider httpProvider, EnvironmentProvider environmentProvider, DiskProvider diskProvider) { diff --git a/NzbDrone.Core/Providers/Core/ArchiveProvider.cs b/NzbDrone.Core/Providers/Core/ArchiveProvider.cs index 48de6a983..c8bb3fd1d 100644 --- a/NzbDrone.Core/Providers/Core/ArchiveProvider.cs +++ b/NzbDrone.Core/Providers/Core/ArchiveProvider.cs @@ -3,7 +3,6 @@ using System.IO; using System.Linq; using Ionic.Zip; using NLog; -using Ninject; using NzbDrone.Common; namespace NzbDrone.Core.Providers.Core diff --git a/NzbDrone.Core/Providers/Core/ConfigProvider.cs b/NzbDrone.Core/Providers/Core/ConfigProvider.cs index 61fecc557..43c6b08db 100644 --- a/NzbDrone.Core/Providers/Core/ConfigProvider.cs +++ b/NzbDrone.Core/Providers/Core/ConfigProvider.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using Ninject; using NLog; using NzbDrone.Core.Model; using NzbDrone.Core.Model.Sabnzbd; @@ -18,7 +17,6 @@ namespace NzbDrone.Core.Providers.Core private readonly IDatabase _database; - [Inject] public ConfigProvider(IDatabase database) { _database = database; diff --git a/NzbDrone.Core/Providers/Core/UdpProvider.cs b/NzbDrone.Core/Providers/Core/UdpProvider.cs index c1b7bbe77..ed0de0b2d 100644 --- a/NzbDrone.Core/Providers/Core/UdpProvider.cs +++ b/NzbDrone.Core/Providers/Core/UdpProvider.cs @@ -4,7 +4,6 @@ using System.Net; using System.Net.Sockets; using System.Text; using NLog; -using Ninject; namespace NzbDrone.Core.Providers.Core { @@ -12,7 +11,6 @@ namespace NzbDrone.Core.Providers.Core { private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); - [Inject] public UdpProvider() { diff --git a/NzbDrone.Core/Providers/DecisionEngine/AcceptableSizeSpecification.cs b/NzbDrone.Core/Providers/DecisionEngine/AcceptableSizeSpecification.cs index 1ff28cf57..4fe35d018 100644 --- a/NzbDrone.Core/Providers/DecisionEngine/AcceptableSizeSpecification.cs +++ b/NzbDrone.Core/Providers/DecisionEngine/AcceptableSizeSpecification.cs @@ -1,6 +1,5 @@ using System.Linq; using NLog; -using Ninject; using NzbDrone.Core.Model; namespace NzbDrone.Core.Providers.DecisionEngine @@ -11,7 +10,6 @@ namespace NzbDrone.Core.Providers.DecisionEngine private readonly EpisodeProvider _episodeProvider; private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - [Inject] public AcceptableSizeSpecification(QualityTypeProvider qualityTypeProvider, EpisodeProvider episodeProvider) { _qualityTypeProvider = qualityTypeProvider; diff --git a/NzbDrone.Core/Providers/DecisionEngine/AllowedDownloadSpecification.cs b/NzbDrone.Core/Providers/DecisionEngine/AllowedDownloadSpecification.cs index 5e29fce41..93d4f59a9 100644 --- a/NzbDrone.Core/Providers/DecisionEngine/AllowedDownloadSpecification.cs +++ b/NzbDrone.Core/Providers/DecisionEngine/AllowedDownloadSpecification.cs @@ -1,6 +1,5 @@ using System.Linq; using NLog; -using Ninject; using NzbDrone.Core.Model; using NzbDrone.Core.Repository.Search; @@ -17,7 +16,6 @@ namespace NzbDrone.Core.Providers.DecisionEngine private readonly CustomStartDateSpecification _customStartDateSpecification; private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - [Inject] public AllowedDownloadSpecification(QualityAllowedByProfileSpecification qualityAllowedByProfileSpecification, UpgradeDiskSpecification upgradeDiskSpecification, AcceptableSizeSpecification acceptableSizeSpecification, AlreadyInQueueSpecification alreadyInQueueSpecification, RetentionSpecification retentionSpecification, diff --git a/NzbDrone.Core/Providers/DecisionEngine/AllowedReleaseGroupSpecification.cs b/NzbDrone.Core/Providers/DecisionEngine/AllowedReleaseGroupSpecification.cs index 4d24886ea..c8c86fb58 100644 --- a/NzbDrone.Core/Providers/DecisionEngine/AllowedReleaseGroupSpecification.cs +++ b/NzbDrone.Core/Providers/DecisionEngine/AllowedReleaseGroupSpecification.cs @@ -1,7 +1,6 @@ using System; using System.Linq; using NLog; -using Ninject; using NzbDrone.Core.Model; using NzbDrone.Core.Providers.Core; @@ -12,7 +11,6 @@ namespace NzbDrone.Core.Providers.DecisionEngine private readonly ConfigProvider _configProvider; private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - [Inject] public AllowedReleaseGroupSpecification(ConfigProvider configProvider) { _configProvider = configProvider; diff --git a/NzbDrone.Core/Providers/DecisionEngine/AlreadyInQueueSpecification.cs b/NzbDrone.Core/Providers/DecisionEngine/AlreadyInQueueSpecification.cs index 02f5a7986..8f4ecedcf 100644 --- a/NzbDrone.Core/Providers/DecisionEngine/AlreadyInQueueSpecification.cs +++ b/NzbDrone.Core/Providers/DecisionEngine/AlreadyInQueueSpecification.cs @@ -1,6 +1,5 @@ using System.Linq; using NLog; -using Ninject; using NzbDrone.Core.Model; namespace NzbDrone.Core.Providers.DecisionEngine @@ -11,7 +10,6 @@ namespace NzbDrone.Core.Providers.DecisionEngine private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - [Inject] public AlreadyInQueueSpecification(DownloadProvider downloadProvider) { _downloadProvider = downloadProvider; diff --git a/NzbDrone.Core/Providers/DecisionEngine/CustomStartDateSpecification.cs b/NzbDrone.Core/Providers/DecisionEngine/CustomStartDateSpecification.cs index c16321ca3..3c30ca362 100644 --- a/NzbDrone.Core/Providers/DecisionEngine/CustomStartDateSpecification.cs +++ b/NzbDrone.Core/Providers/DecisionEngine/CustomStartDateSpecification.cs @@ -1,6 +1,5 @@ using System.Linq; using NLog; -using Ninject; using NzbDrone.Core.Model; namespace NzbDrone.Core.Providers.DecisionEngine diff --git a/NzbDrone.Core/Providers/DecisionEngine/MonitoredEpisodeSpecification.cs b/NzbDrone.Core/Providers/DecisionEngine/MonitoredEpisodeSpecification.cs index d92e79ae5..a719c0b94 100644 --- a/NzbDrone.Core/Providers/DecisionEngine/MonitoredEpisodeSpecification.cs +++ b/NzbDrone.Core/Providers/DecisionEngine/MonitoredEpisodeSpecification.cs @@ -1,6 +1,5 @@ using System.Linq; using NLog; -using Ninject; using NzbDrone.Core.Model; namespace NzbDrone.Core.Providers.DecisionEngine @@ -11,7 +10,6 @@ namespace NzbDrone.Core.Providers.DecisionEngine private readonly EpisodeProvider _episodeProvider; private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - [Inject] public MonitoredEpisodeSpecification(SeriesProvider seriesProvider, EpisodeProvider episodeProvider) { _seriesProvider = seriesProvider; diff --git a/NzbDrone.Core/Providers/DecisionEngine/RetentionSpecification.cs b/NzbDrone.Core/Providers/DecisionEngine/RetentionSpecification.cs index 730af0397..58a86651d 100644 --- a/NzbDrone.Core/Providers/DecisionEngine/RetentionSpecification.cs +++ b/NzbDrone.Core/Providers/DecisionEngine/RetentionSpecification.cs @@ -1,6 +1,5 @@ using System.Linq; using NLog; -using Ninject; using NzbDrone.Core.Model; using NzbDrone.Core.Providers.Core; @@ -11,7 +10,6 @@ namespace NzbDrone.Core.Providers.DecisionEngine private readonly ConfigProvider _configProvider; private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - [Inject] public RetentionSpecification(ConfigProvider configProvider) { _configProvider = configProvider; diff --git a/NzbDrone.Core/Providers/DecisionEngine/UpgradeDiskSpecification.cs b/NzbDrone.Core/Providers/DecisionEngine/UpgradeDiskSpecification.cs index 23e7b7e68..c68b9d333 100644 --- a/NzbDrone.Core/Providers/DecisionEngine/UpgradeDiskSpecification.cs +++ b/NzbDrone.Core/Providers/DecisionEngine/UpgradeDiskSpecification.cs @@ -1,6 +1,5 @@ using System.Linq; using NLog; -using Ninject; using NzbDrone.Core.Model; namespace NzbDrone.Core.Providers.DecisionEngine @@ -11,7 +10,6 @@ namespace NzbDrone.Core.Providers.DecisionEngine private readonly QualityUpgradeSpecification _qualityUpgradeSpecification; private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - [Inject] public UpgradeDiskSpecification(EpisodeProvider episodeProvider, QualityUpgradeSpecification qualityUpgradeSpecification) { _episodeProvider = episodeProvider; diff --git a/NzbDrone.Core/Providers/DecisionEngine/UpgradeHistorySpecification.cs b/NzbDrone.Core/Providers/DecisionEngine/UpgradeHistorySpecification.cs index 11bcb161b..768f81ddd 100644 --- a/NzbDrone.Core/Providers/DecisionEngine/UpgradeHistorySpecification.cs +++ b/NzbDrone.Core/Providers/DecisionEngine/UpgradeHistorySpecification.cs @@ -1,6 +1,5 @@ using System.Linq; using NLog; -using Ninject; using NzbDrone.Core.Model; namespace NzbDrone.Core.Providers.DecisionEngine @@ -12,7 +11,6 @@ namespace NzbDrone.Core.Providers.DecisionEngine private readonly QualityUpgradeSpecification _qualityUpgradeSpecification; private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - [Inject] public UpgradeHistorySpecification(EpisodeProvider episodeProvider, HistoryProvider historyProvider, QualityUpgradeSpecification qualityUpgradeSpecification) { _episodeProvider = episodeProvider; diff --git a/NzbDrone.Core/Providers/DecisionEngine/UpgradePossibleSpecification.cs b/NzbDrone.Core/Providers/DecisionEngine/UpgradePossibleSpecification.cs index 1f5a90e01..42ad0b496 100644 --- a/NzbDrone.Core/Providers/DecisionEngine/UpgradePossibleSpecification.cs +++ b/NzbDrone.Core/Providers/DecisionEngine/UpgradePossibleSpecification.cs @@ -1,6 +1,5 @@ using System.Linq; using NLog; -using Ninject; using NzbDrone.Core.Repository; namespace NzbDrone.Core.Providers.DecisionEngine @@ -10,7 +9,6 @@ namespace NzbDrone.Core.Providers.DecisionEngine private readonly QualityProvider _qualityProvider; private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - [Inject] public UpgradePossibleSpecification(QualityProvider qualityProvider) { _qualityProvider = qualityProvider; diff --git a/NzbDrone.Core/Providers/DiskScanProvider.cs b/NzbDrone.Core/Providers/DiskScanProvider.cs index fd3ab22fa..30126f45a 100644 --- a/NzbDrone.Core/Providers/DiskScanProvider.cs +++ b/NzbDrone.Core/Providers/DiskScanProvider.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using Ninject; using NLog; using NzbDrone.Common; using NzbDrone.Core.Model; @@ -25,7 +24,6 @@ namespace NzbDrone.Core.Providers private readonly ConfigProvider _configProvider; private readonly RecycleBinProvider _recycleBinProvider; - [Inject] public DiskScanProvider(DiskProvider diskProvider, EpisodeProvider episodeProvider, SeriesProvider seriesProvider, MediaFileProvider mediaFileProvider, ExternalNotificationProvider externalNotificationProvider, DownloadProvider downloadProvider, diff --git a/NzbDrone.Core/Providers/DownloadClients/BlackholeProvider.cs b/NzbDrone.Core/Providers/DownloadClients/BlackholeProvider.cs index 3698b2f75..02d288e3d 100644 --- a/NzbDrone.Core/Providers/DownloadClients/BlackholeProvider.cs +++ b/NzbDrone.Core/Providers/DownloadClients/BlackholeProvider.cs @@ -2,7 +2,6 @@ using System.IO; using System.Linq; using NLog; -using Ninject; using NzbDrone.Common; using NzbDrone.Core.Model; using NzbDrone.Core.Providers.Core; @@ -20,7 +19,6 @@ namespace NzbDrone.Core.Providers.DownloadClients private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - [Inject] public BlackholeProvider(ConfigProvider configProvider, HttpProvider httpProvider, DiskProvider diskProvider, UpgradeHistorySpecification upgradeHistorySpecification) { diff --git a/NzbDrone.Core/Providers/DownloadClients/PneumaticProvider.cs b/NzbDrone.Core/Providers/DownloadClients/PneumaticProvider.cs index 1e94da2a6..0845baf13 100644 --- a/NzbDrone.Core/Providers/DownloadClients/PneumaticProvider.cs +++ b/NzbDrone.Core/Providers/DownloadClients/PneumaticProvider.cs @@ -2,7 +2,6 @@ using System.IO; using System.Linq; using NLog; -using Ninject; using NzbDrone.Common; using NzbDrone.Core.Model; using NzbDrone.Core.Providers.Core; @@ -19,7 +18,6 @@ namespace NzbDrone.Core.Providers.DownloadClients private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - [Inject] public PneumaticProvider(ConfigProvider configProvider, HttpProvider httpProvider, DiskProvider diskProvider, UpgradeHistorySpecification upgradeHistorySpecification) { diff --git a/NzbDrone.Core/Providers/DownloadClients/SabProvider.cs b/NzbDrone.Core/Providers/DownloadClients/SabProvider.cs index b085f0178..d004a21ec 100644 --- a/NzbDrone.Core/Providers/DownloadClients/SabProvider.cs +++ b/NzbDrone.Core/Providers/DownloadClients/SabProvider.cs @@ -6,7 +6,6 @@ using System.Text.RegularExpressions; using System.Web; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using Ninject; using NLog; using NzbDrone.Common; using NzbDrone.Core.Model; @@ -21,7 +20,6 @@ namespace NzbDrone.Core.Providers.DownloadClients private readonly ConfigProvider _configProvider; private readonly HttpProvider _httpProvider; - [Inject] public SabProvider(ConfigProvider configProvider, HttpProvider httpProvider) { _configProvider = configProvider; diff --git a/NzbDrone.Core/Providers/DownloadProvider.cs b/NzbDrone.Core/Providers/DownloadProvider.cs index 2df3f63d2..fb070d0de 100644 --- a/NzbDrone.Core/Providers/DownloadProvider.cs +++ b/NzbDrone.Core/Providers/DownloadProvider.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using Ninject; using NLog; using NzbDrone.Core.Model; using NzbDrone.Core.Providers.Core; @@ -23,7 +22,6 @@ namespace NzbDrone.Core.Providers private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - [Inject] public DownloadProvider(SabProvider sabProvider, HistoryProvider historyProvider, EpisodeProvider episodeProvider, ExternalNotificationProvider externalNotificationProvider, ConfigProvider configProvider, BlackholeProvider blackholeProvider, diff --git a/NzbDrone.Core/Providers/EpisodeProvider.cs b/NzbDrone.Core/Providers/EpisodeProvider.cs index 1e44607aa..bfa969ba5 100644 --- a/NzbDrone.Core/Providers/EpisodeProvider.cs +++ b/NzbDrone.Core/Providers/EpisodeProvider.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; -using Ninject; using NLog; using NzbDrone.Core.Model; using NzbDrone.Core.Repository; @@ -20,7 +19,6 @@ namespace NzbDrone.Core.Providers private readonly SeasonProvider _seasonProvider; private readonly IDatabase _database; - [Inject] public EpisodeProvider(IDatabase database, TvDbProvider tvDbProviderProvider, SeasonProvider seasonProvider) { diff --git a/NzbDrone.Core/Providers/ExternalNotificationProvider.cs b/NzbDrone.Core/Providers/ExternalNotificationProvider.cs index f5c14f6cc..e17c50b8b 100644 --- a/NzbDrone.Core/Providers/ExternalNotificationProvider.cs +++ b/NzbDrone.Core/Providers/ExternalNotificationProvider.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using Ninject; using NLog; using NzbDrone.Core.Model; using NzbDrone.Core.Providers.ExternalNotification; @@ -17,7 +16,6 @@ namespace NzbDrone.Core.Providers private IEnumerable _notifiers; - [Inject] public ExternalNotificationProvider(IDatabase database, IEnumerable notifiers) { _database = database; diff --git a/NzbDrone.Core/Providers/HistoryProvider.cs b/NzbDrone.Core/Providers/HistoryProvider.cs index 520ea18a3..2fd9a944c 100644 --- a/NzbDrone.Core/Providers/HistoryProvider.cs +++ b/NzbDrone.Core/Providers/HistoryProvider.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Linq; using DataTables.Mvc.Core.Helpers; using DataTables.Mvc.Core.Models; -using Ninject; using NLog; using NzbDrone.Core.Model; using NzbDrone.Core.Repository; @@ -18,7 +17,6 @@ namespace NzbDrone.Core.Providers private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - [Inject] public HistoryProvider(IDatabase database) { _database = database; diff --git a/NzbDrone.Core/Providers/Indexer/FileSharingTalk.cs b/NzbDrone.Core/Providers/Indexer/FileSharingTalk.cs index fa19df3ec..7c710d11d 100644 --- a/NzbDrone.Core/Providers/Indexer/FileSharingTalk.cs +++ b/NzbDrone.Core/Providers/Indexer/FileSharingTalk.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.ServiceModel.Syndication; using System.Text.RegularExpressions; -using Ninject; using NzbDrone.Common; using NzbDrone.Core.Model; using NzbDrone.Core.Providers.Core; @@ -11,7 +10,6 @@ namespace NzbDrone.Core.Providers.Indexer { public class FileSharingTalk : IndexerBase { - [Inject] public FileSharingTalk(HttpProvider httpProvider, ConfigProvider configProvider) : base(httpProvider, configProvider) { diff --git a/NzbDrone.Core/Providers/Indexer/IndexerBase.cs b/NzbDrone.Core/Providers/Indexer/IndexerBase.cs index af2d363d1..9d8172b40 100644 --- a/NzbDrone.Core/Providers/Indexer/IndexerBase.cs +++ b/NzbDrone.Core/Providers/Indexer/IndexerBase.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Net; using System.ServiceModel.Syndication; using System.Text.RegularExpressions; -using Ninject; using NLog; using NzbDrone.Common; using NzbDrone.Core.Model; @@ -21,7 +20,6 @@ namespace NzbDrone.Core.Providers.Indexer protected static readonly Regex TitleSearchRegex = new Regex(@"[\W]", RegexOptions.IgnoreCase | RegexOptions.Compiled); protected static readonly Regex RemoveThe = new Regex(@"^the\s", RegexOptions.IgnoreCase | RegexOptions.Compiled); - [Inject] protected IndexerBase(HttpProvider httpProvider, ConfigProvider configProvider) { _httpProvider = httpProvider; diff --git a/NzbDrone.Core/Providers/Indexer/Newznab.cs b/NzbDrone.Core/Providers/Indexer/Newznab.cs index 12807e918..ba0ea3433 100644 --- a/NzbDrone.Core/Providers/Indexer/Newznab.cs +++ b/NzbDrone.Core/Providers/Indexer/Newznab.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.ServiceModel.Syndication; using System.Text.RegularExpressions; -using Ninject; using NzbDrone.Common; using NzbDrone.Core.Model; using NzbDrone.Core.Providers.Core; @@ -13,7 +12,6 @@ namespace NzbDrone.Core.Providers.Indexer { private readonly NewznabProvider _newznabProvider; - [Inject] public Newznab(HttpProvider httpProvider, ConfigProvider configProvider, NewznabProvider newznabProvider) : base(httpProvider, configProvider) { diff --git a/NzbDrone.Core/Providers/Indexer/NzbClub.cs b/NzbDrone.Core/Providers/Indexer/NzbClub.cs index c009bb0c2..607c3efad 100644 --- a/NzbDrone.Core/Providers/Indexer/NzbClub.cs +++ b/NzbDrone.Core/Providers/Indexer/NzbClub.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.ServiceModel.Syndication; using System.Text.RegularExpressions; -using Ninject; using NzbDrone.Common; using NzbDrone.Core.Model; using NzbDrone.Core.Providers.Core; @@ -11,7 +10,6 @@ namespace NzbDrone.Core.Providers.Indexer { public class NzbClub : IndexerBase { - [Inject] public NzbClub(HttpProvider httpProvider, ConfigProvider configProvider) : base(httpProvider, configProvider) { diff --git a/NzbDrone.Core/Providers/Indexer/NzbIndex.cs b/NzbDrone.Core/Providers/Indexer/NzbIndex.cs index 8d6b41a59..390da4c50 100644 --- a/NzbDrone.Core/Providers/Indexer/NzbIndex.cs +++ b/NzbDrone.Core/Providers/Indexer/NzbIndex.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.ServiceModel.Syndication; using System.Text.RegularExpressions; -using Ninject; using NzbDrone.Common; using NzbDrone.Core.Model; using NzbDrone.Core.Providers.Core; @@ -11,7 +10,6 @@ namespace NzbDrone.Core.Providers.Indexer { public class NzbIndex : IndexerBase { - [Inject] public NzbIndex(HttpProvider httpProvider, ConfigProvider configProvider) : base(httpProvider, configProvider) { diff --git a/NzbDrone.Core/Providers/Indexer/NzbsRUs.cs b/NzbDrone.Core/Providers/Indexer/NzbsRUs.cs index a1b5bc7b7..ccd61fd5b 100644 --- a/NzbDrone.Core/Providers/Indexer/NzbsRUs.cs +++ b/NzbDrone.Core/Providers/Indexer/NzbsRUs.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.ServiceModel.Syndication; using System.Text.RegularExpressions; -using Ninject; using NzbDrone.Common; using NzbDrone.Core.Model; using NzbDrone.Core.Providers.Core; @@ -11,7 +10,6 @@ namespace NzbDrone.Core.Providers.Indexer { public class NzbsRUs : IndexerBase { - [Inject] public NzbsRUs(HttpProvider httpProvider, ConfigProvider configProvider) : base(httpProvider, configProvider) { } diff --git a/NzbDrone.Core/Providers/Indexer/Nzbx.cs b/NzbDrone.Core/Providers/Indexer/Nzbx.cs index 4feb142ef..f4972cca5 100644 --- a/NzbDrone.Core/Providers/Indexer/Nzbx.cs +++ b/NzbDrone.Core/Providers/Indexer/Nzbx.cs @@ -6,7 +6,6 @@ using System.ServiceModel.Syndication; using System.Text; using System.Text.RegularExpressions; using Newtonsoft.Json; -using Ninject; using NzbDrone.Common; using NzbDrone.Core.Model; using NzbDrone.Core.Model.Nzbx; @@ -16,7 +15,6 @@ namespace NzbDrone.Core.Providers.Indexer { class Nzbx : IndexerBase { - [Inject] public Nzbx(HttpProvider httpProvider, ConfigProvider configProvider) : base(httpProvider, configProvider) { diff --git a/NzbDrone.Core/Providers/Indexer/Omgwtfnzbs.cs b/NzbDrone.Core/Providers/Indexer/Omgwtfnzbs.cs index eea4b9d6a..a97b6d63a 100644 --- a/NzbDrone.Core/Providers/Indexer/Omgwtfnzbs.cs +++ b/NzbDrone.Core/Providers/Indexer/Omgwtfnzbs.cs @@ -4,7 +4,6 @@ using System.Linq; using System.ServiceModel.Syndication; using System.Text; using System.Text.RegularExpressions; -using Ninject; using NzbDrone.Common; using NzbDrone.Core.Model; using NzbDrone.Core.Providers.Core; @@ -13,7 +12,6 @@ namespace NzbDrone.Core.Providers.Indexer { class Omgwtfnzbs : IndexerBase { - [Inject] public Omgwtfnzbs(HttpProvider httpProvider, ConfigProvider configProvider) : base(httpProvider, configProvider) { diff --git a/NzbDrone.Core/Providers/Indexer/Wombles.cs b/NzbDrone.Core/Providers/Indexer/Wombles.cs index e454235a2..f61906e37 100644 --- a/NzbDrone.Core/Providers/Indexer/Wombles.cs +++ b/NzbDrone.Core/Providers/Indexer/Wombles.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.ServiceModel.Syndication; using System.Text.RegularExpressions; -using Ninject; using NzbDrone.Common; using NzbDrone.Core.Model; using NzbDrone.Core.Providers.Core; @@ -11,7 +10,6 @@ namespace NzbDrone.Core.Providers.Indexer { public class Wombles : IndexerBase { - [Inject] public Wombles(HttpProvider httpProvider, ConfigProvider configProvider) : base(httpProvider, configProvider) { } diff --git a/NzbDrone.Core/Providers/IndexerProvider.cs b/NzbDrone.Core/Providers/IndexerProvider.cs index 3ff70d824..8c3703121 100644 --- a/NzbDrone.Core/Providers/IndexerProvider.cs +++ b/NzbDrone.Core/Providers/IndexerProvider.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using Ninject; using NLog; using NzbDrone.Core.Providers.Indexer; using NzbDrone.Core.Repository; @@ -16,7 +15,6 @@ namespace NzbDrone.Core.Providers private IEnumerable _indexers; - [Inject] public IndexerProvider(IDatabase database, IEnumerable indexers) { _database = database; diff --git a/NzbDrone.Core/Providers/MediaFileProvider.cs b/NzbDrone.Core/Providers/MediaFileProvider.cs index 9310447eb..c0e630dc8 100644 --- a/NzbDrone.Core/Providers/MediaFileProvider.cs +++ b/NzbDrone.Core/Providers/MediaFileProvider.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; -using Ninject; using NLog; using NzbDrone.Core.Helpers; using NzbDrone.Core.Providers.Core; @@ -20,7 +19,6 @@ namespace NzbDrone.Core.Providers private readonly IDatabase _database; private readonly EpisodeProvider _episodeProvider; - [Inject] public MediaFileProvider(EpisodeProvider episodeProvider, ConfigProvider configProvider, IDatabase database) { _episodeProvider = episodeProvider; diff --git a/NzbDrone.Core/Providers/MetadataProvider.cs b/NzbDrone.Core/Providers/MetadataProvider.cs index caad52dba..b5ca8146e 100644 --- a/NzbDrone.Core/Providers/MetadataProvider.cs +++ b/NzbDrone.Core/Providers/MetadataProvider.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using Ninject; using NLog; using NzbDrone.Core.Model; using NzbDrone.Core.Providers.ExternalNotification; @@ -20,7 +19,6 @@ namespace NzbDrone.Core.Providers private IEnumerable _metadataProviders; private readonly TvDbProvider _tvDbProvider; - [Inject] public MetadataProvider(IDatabase database, IEnumerable metadataProviders, TvDbProvider tvDbProvider) { diff --git a/NzbDrone.Core/Providers/NewznabProvider.cs b/NzbDrone.Core/Providers/NewznabProvider.cs index ac6964dd7..5c91de71a 100644 --- a/NzbDrone.Core/Providers/NewznabProvider.cs +++ b/NzbDrone.Core/Providers/NewznabProvider.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Net; -using Ninject; using NLog; using NzbDrone.Core.Providers.Indexer; using NzbDrone.Core.Repository; @@ -15,7 +14,6 @@ namespace NzbDrone.Core.Providers private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private readonly IDatabase _database; - [Inject] public NewznabProvider(IDatabase database) { _database = database; diff --git a/NzbDrone.Core/Providers/PlexProvider.cs b/NzbDrone.Core/Providers/PlexProvider.cs index 05106b7d1..64c748bb8 100644 --- a/NzbDrone.Core/Providers/PlexProvider.cs +++ b/NzbDrone.Core/Providers/PlexProvider.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Text; using System.Xml.Linq; using NLog; -using Ninject; using NzbDrone.Common; using NzbDrone.Core.Providers.Core; @@ -17,7 +16,6 @@ namespace NzbDrone.Core.Providers private readonly ConfigProvider _configProvider; private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - [Inject] public PlexProvider(HttpProvider httpProvider, ConfigProvider configProvider) { _httpProvider = httpProvider; diff --git a/NzbDrone.Core/Providers/PostDownloadProvider.cs b/NzbDrone.Core/Providers/PostDownloadProvider.cs index 22208e732..bdf192641 100644 --- a/NzbDrone.Core/Providers/PostDownloadProvider.cs +++ b/NzbDrone.Core/Providers/PostDownloadProvider.cs @@ -3,7 +3,6 @@ using System.IO; using System.Linq; using System.Text.RegularExpressions; using NLog; -using Ninject; using NzbDrone.Common; using NzbDrone.Core.Model; @@ -19,7 +18,6 @@ namespace NzbDrone.Core.Providers private readonly SeriesProvider _seriesProvider; private readonly MetadataProvider _metadataProvider; - [Inject] public PostDownloadProvider(DiskProvider diskProvider, DiskScanProvider diskScanProvider, SeriesProvider seriesProvider, MetadataProvider metadataProvider) { diff --git a/NzbDrone.Core/Providers/QualityProvider.cs b/NzbDrone.Core/Providers/QualityProvider.cs index 1842c1f07..a1240276d 100644 --- a/NzbDrone.Core/Providers/QualityProvider.cs +++ b/NzbDrone.Core/Providers/QualityProvider.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using Ninject; using NLog; using NzbDrone.Core.Repository.Quality; using PetaPoco; @@ -17,7 +16,6 @@ namespace NzbDrone.Core.Providers { } - [Inject] public QualityProvider(IDatabase database) { _database = database; diff --git a/NzbDrone.Core/Providers/RecycleBinProvider.cs b/NzbDrone.Core/Providers/RecycleBinProvider.cs index 698f38619..3d1bd4757 100644 --- a/NzbDrone.Core/Providers/RecycleBinProvider.cs +++ b/NzbDrone.Core/Providers/RecycleBinProvider.cs @@ -4,7 +4,6 @@ using System.IO; using System.Linq; using System.Text; using NLog; -using Ninject; using NzbDrone.Common; using NzbDrone.Core.Providers.Core; @@ -17,7 +16,6 @@ namespace NzbDrone.Core.Providers private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - [Inject] public RecycleBinProvider(DiskProvider diskProvider, ConfigProvider configProvider) { _diskProvider = diskProvider; diff --git a/NzbDrone.Core/Providers/RootDirProvider.cs b/NzbDrone.Core/Providers/RootDirProvider.cs index 0e22e0f14..34f3bab1e 100644 --- a/NzbDrone.Core/Providers/RootDirProvider.cs +++ b/NzbDrone.Core/Providers/RootDirProvider.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using Ninject; using NLog; using NzbDrone.Common; using NzbDrone.Core.Model; @@ -18,7 +17,6 @@ namespace NzbDrone.Core.Providers private readonly DiskProvider _diskProvider; private readonly SeriesProvider _seriesProvider; - [Inject] public RootDirProvider(IDatabase database, SeriesProvider seriesProvider, DiskProvider diskProvider) { _database = database; diff --git a/NzbDrone.Core/Providers/SceneMappingProvider.cs b/NzbDrone.Core/Providers/SceneMappingProvider.cs index bc0f6b61d..d4f119d80 100644 --- a/NzbDrone.Core/Providers/SceneMappingProvider.cs +++ b/NzbDrone.Core/Providers/SceneMappingProvider.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.IO; using NLog; using Newtonsoft.Json; -using Ninject; using NzbDrone.Common; using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Repository; @@ -18,7 +17,6 @@ namespace NzbDrone.Core.Providers private readonly HttpProvider _httpProvider; private readonly ConfigProvider _configProvider; - [Inject] public SceneMappingProvider(IDatabase database, HttpProvider httpProvider, ConfigProvider configProvider) { _database = database; diff --git a/NzbDrone.Core/Providers/SearchHistoryProvider.cs b/NzbDrone.Core/Providers/SearchHistoryProvider.cs index f746d18a3..50231b8f2 100644 --- a/NzbDrone.Core/Providers/SearchHistoryProvider.cs +++ b/NzbDrone.Core/Providers/SearchHistoryProvider.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Linq; using System.Text; using NLog; -using Ninject; using NzbDrone.Core.Repository; using NzbDrone.Core.Repository.Search; using PetaPoco; @@ -19,7 +18,6 @@ namespace NzbDrone.Core.Providers private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - [Inject] public SearchHistoryProvider(IDatabase database, SeriesProvider seriesProvider, DownloadProvider downloadProvider, EpisodeProvider episodeProvider) { diff --git a/NzbDrone.Core/Providers/SearchProvider.cs b/NzbDrone.Core/Providers/SearchProvider.cs index 5c611ff56..b6a84888e 100644 --- a/NzbDrone.Core/Providers/SearchProvider.cs +++ b/NzbDrone.Core/Providers/SearchProvider.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using NLog; -using Ninject; using NzbDrone.Core.Model; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers.DecisionEngine; @@ -26,7 +25,6 @@ namespace NzbDrone.Core.Providers private static readonly Logger logger = LogManager.GetCurrentClassLogger(); - [Inject] public SearchProvider(EpisodeProvider episodeProvider, DownloadProvider downloadProvider, SeriesProvider seriesProvider, IndexerProvider indexerProvider, SceneMappingProvider sceneMappingProvider, UpgradePossibleSpecification upgradePossibleSpecification, AllowedDownloadSpecification allowedDownloadSpecification, diff --git a/NzbDrone.Core/Providers/SeasonProvider.cs b/NzbDrone.Core/Providers/SeasonProvider.cs index ed233c68e3691fc150d9cbcf279cf0a47e7f0ad6..500fc5c58fa63400359dc3cd676ec39ebec693d1 100644 GIT binary patch delta 15 WcmaE4e!zT!@5We9#?3nzwWI(y%LVoT delta 31 jcmX?L{>XfSFI#3_R%&v|M(1Egj%ZIXJ9cvqqlpv%#4ZbD diff --git a/NzbDrone.Core/Providers/SeriesProvider.cs b/NzbDrone.Core/Providers/SeriesProvider.cs index d555c290e..9a0d94f5f 100644 --- a/NzbDrone.Core/Providers/SeriesProvider.cs +++ b/NzbDrone.Core/Providers/SeriesProvider.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using NLog; -using Ninject; using NzbDrone.Common; using NzbDrone.Core.Model; using NzbDrone.Core.Providers.Core; @@ -28,7 +27,6 @@ namespace NzbDrone.Core.Providers private static readonly Regex TimeRegex = new Regex(@"^(?