1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-10-30 07:22:35 +01:00
Sonarr/NzbDrone/CentralDispatch.cs
2013-01-02 19:04:42 -08:00

62 lines
2.2 KiB
C#

using Autofac;
using NLog;
using NzbDrone.Common;
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.RegisterType<ApplicationServer>().SingleInstance();
builder.RegisterType<ConfigFileProvider>().SingleInstance();
builder.RegisterType<ConsoleProvider>().SingleInstance();
builder.RegisterType<DebuggerProvider>().SingleInstance();
builder.RegisterType<EnvironmentProvider>().SingleInstance();
builder.RegisterType<IISProvider>().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);
}
}
}