//Our composition Root protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); //var emailConfig = ConfigurationManager.GetSection("EmailLogger") as EmailLogConfiguration; //TODO: Ensure Web.Config is correctly configured. //if (emailConfig == null) //throw new ConfigurationErrorsException("Email Logger was not configured correctly"); //ILogger emailLoggingProvider = new EmailLogger(emailConfig); SqlLoggingRepository sqlLogRepo = new SqlLoggingRepository(); ILogger sqlLoggingProvider = new SqlLogger(sqlLogRepo); Global.Logger = new LoggingService(sqlLoggingProvider); string userName = ConfigurationManager.AppSettings["AdminDefaultUserName"]; if (Membership.FindUsersByName(userName).Count == 0) { string password = ConfigurationManager.AppSettings["AdminDefaultPassword"]; string email = ConfigurationManager.AppSettings["AdminDefaultEmail"]; MembershipCreateStatus createStatus; Membership.CreateUser(userName, password, email, passwordQuestion: null, passwordAnswer: null, isApproved: true, providerUserKey: null, status: out createStatus); if (createStatus != MembershipCreateStatus.Success) throw new MembershipCreateUserException(createStatus.ToString()); } var unhandledErrorAttr = new LoggingHandleErrorAttribute(Global.Logger); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters, new object[] { unhandledErrorAttr }); //Database.SetInitializer<PersonalWebsiteContext>(new ContextInitializer()); //TODO: var controllerFactory = new PersonalWebsiteControllerFactory(); //TODO: ControllerBuilder.Current.SetControllerFactory(controllerFactory); }
public SqlLogger(SqlLoggingRepository repo) { _repo = repo; }