replaced owin's ITraceOutputFactory to one based on nlog that should work on linux.

This commit is contained in:
Keivan Beigi 2013-08-28 15:25:12 -07:00
parent 9b9e1e20eb
commit 6c7e12da5b
3 changed files with 8 additions and 20 deletions

View File

@ -26,7 +26,6 @@ namespace NzbDrone.Host
Container.Register(typeof(IBasicRepository<RootFolder>), typeof(BasicRepository<RootFolder>));
Container.Register(typeof(IBasicRepository<NamingConfig>), typeof(BasicRepository<NamingConfig>));
Container.Register(typeof(System.IServiceProvider), typeof(OwinServiceProvider));
Container.Register<INancyBootstrapper, NancyBootstrapper>();
}

View File

@ -14,15 +14,13 @@ namespace NzbDrone.Host.Owin
{
private readonly IConfigFileProvider _configFileProvider;
private readonly IEnumerable<IOwinMiddleWare> _owinMiddleWares;
private readonly IServiceProvider _serviceProvider;
private readonly Logger _logger;
private IDisposable _host;
public OwinHostController(IConfigFileProvider configFileProvider, IEnumerable<IOwinMiddleWare> owinMiddleWares, IServiceProvider serviceProvider, Logger logger)
public OwinHostController(IConfigFileProvider configFileProvider, IEnumerable<IOwinMiddleWare> 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)

View File

@ -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()
public static ServiceProvider Create()
{
_defaultProvider = ServicesFactory.Create();
}
public object GetService(Type serviceType)
{
if (serviceType == typeof (ITraceOutputFactory))
{
return new OwinTraceOutputFactory();
}
var provider = (ServiceProvider)ServicesFactory.Create();
provider.Add(typeof(ITraceOutputFactory), typeof(OwinTraceOutputFactory));
return _defaultProvider.GetService(serviceType);
return provider;
}
}
}