diff --git a/Marr.Data/Marr.Data.csproj b/Marr.Data/Marr.Data.csproj
index 6cd601100..060887697 100644
--- a/Marr.Data/Marr.Data.csproj
+++ b/Marr.Data/Marr.Data.csproj
@@ -20,7 +20,8 @@
3.5
-
+
+
..\
true
diff --git a/NzbDrone.Api/ApiContainerExtensions.cs b/NzbDrone.Api/ApiContainerExtensions.cs
deleted file mode 100644
index 01ca85966..000000000
--- a/NzbDrone.Api/ApiContainerExtensions.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using System.Linq;
-using Autofac;
-using Nancy.Bootstrapper;
-using NzbDrone.Common;
-
-namespace NzbDrone.Api
-{
- public static class ApiContainerExtensions
- {
- public static void RegisterApiServices(this ContainerBuilder containerBuilder)
- {
- containerBuilder.RegisterAssemblyTypes("NzbDrone.Api");
- containerBuilder.RegisterType().As();
- }
- }
-}
\ No newline at end of file
diff --git a/NzbDrone.Api/Extensions/RootPathProvider.cs b/NzbDrone.Api/Extensions/RootPathProvider.cs
deleted file mode 100644
index 8f19bdb73..000000000
--- a/NzbDrone.Api/Extensions/RootPathProvider.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System.IO;
-using System.Linq;
-using Nancy;
-
-namespace NzbDrone.Api.Extensions
-{
- public class RootPathProvider : IRootPathProvider
- {
- public string GetRootPath()
- {
- return Directory.GetCurrentDirectory();
- }
- }
-}
\ No newline at end of file
diff --git a/NzbDrone.Api/NancyBootstrapper.cs b/NzbDrone.Api/NancyBootstrapper.cs
index 4b7535f2e..6fad25955 100644
--- a/NzbDrone.Api/NancyBootstrapper.cs
+++ b/NzbDrone.Api/NancyBootstrapper.cs
@@ -1,54 +1,48 @@
using System;
using System.Collections.Generic;
-using Autofac;
using NLog;
-using Nancy;
using Nancy.Bootstrapper;
-using Nancy.Bootstrappers.Autofac;
using Nancy.Conventions;
using Nancy.Diagnostics;
using NzbDrone.Api.ErrorManagement;
using NzbDrone.Api.Extensions;
using NzbDrone.Api.Frontend;
using NzbDrone.Common;
-using NzbDrone.Core;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Lifecycle;
-using SignalR;
+using TinyIoC;
using ErrorPipeline = NzbDrone.Api.ErrorManagement.ErrorPipeline;
namespace NzbDrone.Api
{
-
- public class NancyBootstrapper : AutofacNancyBootstrapper
+ public class TinyNancyBootstrapper : TinyIoCNancyBootstrapper
{
+ private readonly TinyIoCContainer _tinyIoCContainer;
private readonly Logger _logger;
- public NancyBootstrapper()
+ public TinyNancyBootstrapper(TinyIoCContainer tinyIoCContainer)
{
+ _tinyIoCContainer = tinyIoCContainer;
_logger = LogManager.GetCurrentClassLogger();
}
- protected override Nancy.IRootPathProvider RootPathProvider
- {
- get
- {
- return new RootPathProvider();
- }
- }
-
- protected override void ApplicationStartup(ILifetimeScope container, IPipelines pipelines)
+ protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
{
_logger.Info("Starting NzbDrone API");
AutomapperBootstraper.InitializeAutomapper();
- SignalRBootstraper.InitializeAutomapper(container);
RegisterReporting(container);
KickoffInitilizables(container);
ApplicationPipelines.OnError.AddItemToEndOfPipeline(container.Resolve().HandleException);
}
- private void KickoffInitilizables(ILifetimeScope container)
+ private void RegisterReporting(TinyIoCContainer container)
+ {
+ EnvironmentProvider.UGuid = container.Resolve().UGuid;
+ ReportingService.RestProvider = container.Resolve();
+ }
+
+ private void KickoffInitilizables(TinyIoCContainer container)
{
var initilizables = container.Resolve>();
@@ -67,23 +61,10 @@ namespace NzbDrone.Api
}
}
- private void RegisterReporting(ILifetimeScope container)
- {
- EnvironmentProvider.UGuid = container.Resolve().UGuid;
- ReportingService.RestProvider = container.Resolve();
- }
- protected override ILifetimeScope GetApplicationContainer()
+ protected override TinyIoCContainer GetApplicationContainer()
{
- _logger.Debug("Initializing Service Container");
-
- var builder = new ContainerBuilder();
- builder.RegisterCoreServices();
- builder.RegisterApiServices();
-
- var container = builder.Build();
-
- return container;
+ return _tinyIoCContainer;
}
protected override NancyInternalConfiguration InternalConfiguration
@@ -110,15 +91,5 @@ namespace NzbDrone.Api
var processors = ApplicationContainer.Resolve();
Conventions.StaticContentsConventions.Add(processors.ProcessStaticResourceRequest);
}
-
- }
-
- public static class SignalRBootstraper
- {
-
- public static void InitializeAutomapper(ILifetimeScope container)
- {
- GlobalHost.DependencyResolver = new AutofacSignalrDependencyResolver(container.BeginLifetimeScope("SignalR"));
- }
}
}
\ No newline at end of file
diff --git a/NzbDrone.Api/NzbDrone.Api.csproj b/NzbDrone.Api/NzbDrone.Api.csproj
index 75a2cf157..cad11de30 100644
--- a/NzbDrone.Api/NzbDrone.Api.csproj
+++ b/NzbDrone.Api/NzbDrone.Api.csproj
@@ -13,6 +13,8 @@
512
..\
true
+
+
true
@@ -53,10 +55,6 @@
-
- False
- ..\packages\Autofac.3.0.1\lib\net40\Autofac.dll
-
False
..\packages\AutoMapper.2.2.1\lib\net40\AutoMapper.dll
@@ -68,10 +66,6 @@
False
..\packages\Nancy.0.16.1\lib\net40\Nancy.dll
-
- False
- ..\packages\Nancy.Bootstrappers.Autofac.0.16.1\lib\net40\Nancy.Bootstrappers.Autofac.dll
-
False
..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll
@@ -94,7 +88,6 @@
-
@@ -111,7 +104,6 @@
-
@@ -133,6 +125,8 @@
+
+
diff --git a/NzbDrone.Api/TinyIoCDependencyResolver.cs b/NzbDrone.Api/TinyIoCDependencyResolver.cs
new file mode 100644
index 000000000..e045a9b1d
--- /dev/null
+++ b/NzbDrone.Api/TinyIoCDependencyResolver.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using SignalR;
+using TinyIoC;
+
+namespace NzbDrone.Api
+{
+ public class TinyIoCDependencyResolver : DefaultDependencyResolver
+ {
+ private readonly TinyIoCContainer _container;
+
+ public TinyIoCDependencyResolver(TinyIoCContainer container)
+ {
+ _container = container;
+ }
+
+ public override object GetService(Type serviceType)
+ {
+ if (_container.CanResolve(serviceType))
+ {
+ return _container.Resolve(serviceType);
+ }
+
+ return base.GetService(serviceType);
+ }
+
+ public override IEnumerable