public static void Inject() { var configbuilder = new ContainerBuilder(); configbuilder.RegisterType <FileSettingsLoader>().As <ISettingsLoader>(); var configcontainer = configbuilder.Build(); ISettingsLoader i = configcontainer.Resolve <ISettingsLoader>(); GlobalSettings = i.LoadSettings(); builder.RegisterInstance(i).As <ISettingsLoader>(); if (GlobalSettings.BlogDb == DbType.MONGODB) { builder.RegisterInstance(new MongoDbDataHelper(GlobalSettings)).As <IDataHelper, IBlogSettingsLoader>(); } else if (GlobalSettings.BlogDb == DbType.EF) { builder.RegisterInstance(new EfDataHelper(GlobalSettings)).As <IDataHelper, IBlogSettingsLoader>(); } else if (GlobalSettings.BlogDb == DbType.RAVENDB) { builder.RegisterInstance(new RavenDataHelper(GlobalSettings, HttpContext.Current.Server.MapPath(GlobalSettings.LocalDbPath))).As <IDataHelper, IBlogSettingsLoader>().SingleInstance(); } if (GlobalSettings.BlogEmailMethod == EmailType.SMTP) { builder.RegisterInstance(new SmtpEmailProvider(GlobalSettings)).As <IEmailSend>(); } else if (GlobalSettings.BlogEmailMethod == EmailType.API) { builder.RegisterInstance(new ApiEmailProvider(GlobalSettings)).As <IEmailSend>(); } builder.RegisterControllers(Assembly.GetExecutingAssembly()); builder.RegisterApiControllers(Assembly.GetExecutingAssembly()); builder.RegisterSource(new ViewRegistrationSource()); container = builder.Build(); // get dbhelper. IDataHelper h = container.Resolve <IDataHelper>(); var installresult = h.CheckInstall(GlobalSettings); if (installresult) { RouteConfig.RegisterRoutes(RouteTable.Routes, h); IBlogSettingsLoader b = container.Resolve <IBlogSettingsLoader>(); GenerateVE(b.LoadSettings().BlogTheme); // check for enabled plugins. DependencyResolver.SetResolver(new AutofacDependencyResolver(container)); var resolver = new AutofacWebApiDependencyResolver(container); GlobalConfiguration.Configuration.DependencyResolver = resolver; } else { } //install }