diff --git a/NzbDrone.Host/MainAppContainerBuilder.cs b/NzbDrone.Host/MainAppContainerBuilder.cs index ecebe6e70..e12fc9153 100644 --- a/NzbDrone.Host/MainAppContainerBuilder.cs +++ b/NzbDrone.Host/MainAppContainerBuilder.cs @@ -26,7 +26,6 @@ namespace NzbDrone.Host Container.Register(typeof(IBasicRepository), typeof(BasicRepository)); Container.Register(typeof(IBasicRepository), typeof(BasicRepository)); - Container.Register(typeof(System.IServiceProvider), typeof(OwinServiceProvider)); Container.Register(); } diff --git a/NzbDrone.Host/Owin/OwinHostController.cs b/NzbDrone.Host/Owin/OwinHostController.cs index 447ac71d0..a571d5530 100644 --- a/NzbDrone.Host/Owin/OwinHostController.cs +++ b/NzbDrone.Host/Owin/OwinHostController.cs @@ -14,15 +14,13 @@ namespace NzbDrone.Host.Owin { private readonly IConfigFileProvider _configFileProvider; private readonly IEnumerable _owinMiddleWares; - private readonly IServiceProvider _serviceProvider; private readonly Logger _logger; private IDisposable _host; - public OwinHostController(IConfigFileProvider configFileProvider, IEnumerable owinMiddleWares, IServiceProvider serviceProvider, Logger logger) + public OwinHostController(IConfigFileProvider configFileProvider, IEnumerable owinMiddleWares, Logger logger) { _configFileProvider = configFileProvider; _owinMiddleWares = owinMiddleWares; - _serviceProvider = serviceProvider; _logger = logger; } @@ -39,7 +37,7 @@ namespace NzbDrone.Host.Owin _logger.Info("starting server on {0}", url); - _host = WebApp.Start(_serviceProvider, options, BuildApp); + _host = WebApp.Start(OwinServiceProviderFactory.Create(), options, BuildApp); } private void BuildApp(IAppBuilder appBuilder) diff --git a/NzbDrone.Host/Owin/OwinServiceProvider.cs b/NzbDrone.Host/Owin/OwinServiceProvider.cs index e13c76191..cffea738f 100644 --- a/NzbDrone.Host/Owin/OwinServiceProvider.cs +++ b/NzbDrone.Host/Owin/OwinServiceProvider.cs @@ -1,25 +1,16 @@ -using System; -using Microsoft.Owin.Hosting.Services; +using Microsoft.Owin.Hosting.Services; using Microsoft.Owin.Hosting.Tracing; namespace NzbDrone.Host.Owin { - public class OwinServiceProvider : IServiceProvider + public static class OwinServiceProviderFactory { - private readonly IServiceProvider _defaultProvider; - - public OwinServiceProvider() - { - _defaultProvider = ServicesFactory.Create(); - } - public object GetService(Type serviceType) + public static ServiceProvider Create() { - if (serviceType == typeof (ITraceOutputFactory)) - { - return new OwinTraceOutputFactory(); - } + var provider = (ServiceProvider)ServicesFactory.Create(); + provider.Add(typeof(ITraceOutputFactory), typeof(OwinTraceOutputFactory)); - return _defaultProvider.GetService(serviceType); + return provider; } } } \ No newline at end of file