Esempio n. 1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Register injectable things
            DI.RegisterTransient <IRepository <Picture>, DatabaseRepository <Picture> >();
            DI.RegisterTransient <IRepository <Tag>, DatabaseRepository <Tag> >();

            // Add DI to our controllers
            ControllerBuilder.Current.SetControllerFactory(typeof(InjectingControllerFactory));             // MVC controllers only, doing this for Web API sucks
        }
Esempio n. 2
0
 protected void Application_EndRequest()
 {
     DI.UnregisterScoped(HttpContext.Current.Items["Context"]);
 }
Esempio n. 3
0
 protected void Application_BeginRequest()
 {
     HttpContext.Current.Items["Context"] = Guid.NewGuid();
     DI.RegisterScoped(HttpContext.Current.Items["Context"], new PictureTaggerContext());
 }