1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-14 11:23:42 +02:00
Sonarr/NzbDrone/CentralDispatch.cs
2013-02-18 17:13:42 -08:00

68 lines
2.4 KiB
C#

using Autofac;
using NLog;
using Nancy.Bootstrapper;
using NzbDrone.Api;
using NzbDrone.Common;
using NzbDrone.Core.Instrumentation;
using NzbDrone.Providers;
namespace NzbDrone
{
public static class CentralDispatch
{
private static IContainer _container;
private static readonly Logger Logger = LogManager.GetLogger("Host.CentralDispatch");
static CentralDispatch()
{
var builder = new ContainerBuilder();
BindKernel(builder);
_container = builder.Build();
InitilizeApp();
}
public static IContainer Container
{
get
{
return _container;
}
}
private static void BindKernel(ContainerBuilder builder)
{
builder.RegisterAssemblyTypes(typeof(DiskProvider).Assembly).SingleInstance();
builder.RegisterType<Router>();
builder.RegisterModule<LogInjectionModule>();
builder.RegisterType<NancyBootstrapper>().As<INancyBootstrapper>().SingleInstance();
builder.RegisterType<ApplicationServer>().SingleInstance();
builder.RegisterType<ConfigFileProvider>().SingleInstance();
builder.RegisterType<ConsoleProvider>().SingleInstance();
builder.RegisterType<EnvironmentProvider>().SingleInstance();
builder.RegisterType<HostController>().SingleInstance();
builder.RegisterType<MonitoringProvider>().SingleInstance();
builder.RegisterType<ProcessProvider>().SingleInstance();
builder.RegisterType<ServiceProvider>().SingleInstance();
builder.RegisterType<HttpProvider>().SingleInstance();
}
private static void InitilizeApp()
{
var environmentProvider = _container.Resolve<EnvironmentProvider>();
ReportingService.RestProvider = _container.Resolve<RestProvider>();
ReportingService.SetupExceptronDriver();
LogConfiguration.RegisterRollingFileLogger(environmentProvider.GetLogFileName(), LogLevel.Info);
LogConfiguration.RegisterConsoleLogger(LogLevel.Debug);
LogConfiguration.RegisterUdpLogger();
LogConfiguration.RegisterRemote();
LogConfiguration.Reload();
Logger.Info("Start-up Path:'{0}'", environmentProvider.ApplicationPath);
}
}
}