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().SingleInstance(); builder.RegisterType().SingleInstance(); builder.RegisterType().SingleInstance(); builder.RegisterType().SingleInstance(); builder.RegisterType().SingleInstance(); builder.RegisterType().SingleInstance(); builder.RegisterType().SingleInstance(); builder.RegisterType().SingleInstance(); builder.RegisterType().SingleInstance(); builder.RegisterType().SingleInstance(); } private static void InitilizeApp() { var environmentProvider = _container.Resolve(); ReportingService.RestProvider = _container.Resolve(); 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); } } }