protected void Application_Start(object sender, EventArgs e) { var builder = new ContainerBuilder(); builder.RegisterModelBinders(Assembly.GetExecutingAssembly()); builder.RegisterModelBinderProvider(); builder.RegisterControllers(Assembly.GetExecutingAssembly()); builder.RegisterType<AuthenticationService>().As<IAuthenticationService>(); builder.RegisterModule<AutofacWebTypesModule>(); builder.RegisterModule<NHibernateModule>(); // Change controller action parameter injection by changing web.config. builder.RegisterType<ExtensibleActionInvoker>().As<IActionInvoker>().InstancePerRequest(); // MVC integration test items builder.RegisterType<InvokerDependency>().As<IInvokerDependency>(); // DomainServices builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly()).AssignableTo<DomainService>(); builder.RegisterModule<AutofacDomainServiceModule>(); IContainer container = builder.Build(); _containerProvider = new ContainerProvider(container); DependencyResolver.SetResolver(new AutofacDependencyResolver(container)); DomainService.Factory = new AutofacDomainServiceFactory(new MvcContainerProvider()); RegisterRoutes(RouteTable.Routes); }
public TestContainer() { var builder = new ContainerBuilder(); builder.Register<MockVisitorRepository>().As<IRepository<Visitor>>().SingletonScoped(); builder.Register<MD5Helper>().As<ICryptoHelper>().SingletonScoped(); builder.RegisterModule(new AutofacControllerModule(Assembly.GetExecutingAssembly())); this.container = builder.Build(); this.containerProvider = new ContainerProvider(container); ControllerBuilder.Current.SetControllerFactory(new AutofacControllerFactory(containerProvider)); }
protected void Application_Start() { var builder = new ContainerBuilder(); builder.RegisterModule(new BootstrapperModule()); builder.RegisterControllers(Assembly.GetExecutingAssembly()); _containerProvider = new ContainerProvider(builder.Build()); ControllerBuilder.Current.SetControllerFactory(new AutofacControllerFactory(_containerProvider)); AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); BundleTable.Bundles.RegisterTemplateBundles(); var container = new ContainerProvider(IoCContainer.CreateContainer()); ControllerBuilder.Current.SetControllerFactory(new AutofacControllerFactory(container)); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); var container = ConfigureAutofacContainer(); _containterProvider = new ContainerProvider(container); DependencyResolver.SetResolver(new AutofacDependencyResolver(container)); }
protected void Application_Start() { var builder = new ContainerBuilder(); //builder.RegisterModelBinders(Assembly.GetExecutingAssembly()); builder.RegisterControllers(Assembly.GetExecutingAssembly()); builder.RegisterModule<ModelModule>(); builder.RegisterType<AccountMembershipService>().InstancePerHttpRequest(); _containerProvider = new ContainerProvider(builder.Build()); // Set the controller factory using the container provider. ControllerBuilder.Current.SetControllerFactory(new AutofacControllerFactory(ContainerProvider)); AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes); }
public void NewJob_Injects_Properties() { //Arrange var builder = new ContainerBuilder(); var assembly = typeof(HomeController).Assembly; ComponentRegistrar.AddComponentsTo(builder, assembly); var containerProvider = new ContainerProvider(builder.Build()); var jobDetail = new JobDetail("blag", null, typeof (OddJob)); var trigger = TriggerUtils.MakeImmediateTrigger(0, TimeSpan.FromSeconds(2)); var bundle = new TriggerFiredBundle(jobDetail, trigger, null, false, null, null, null, null); var factory = new AutofacJobFactory(containerProvider); //Act var job = factory.NewJob(bundle) as OddJob; //Assert Assert.IsNotNull(job.ProductTasks); }
public override RouteData GetRouteData(HttpContextBase httpContext) { // locate appropriate shell settings for request var settings = _runningShellTable.Match(httpContext); // only proceed if there was a match, and it was for this client if (settings == null || settings.Name != _shellSettings.Name) return null; var effectiveHttpContext = httpContext; if (_urlPrefix != null) effectiveHttpContext = new UrlPrefixAdjustedHttpContext(httpContext, _urlPrefix); var routeData = _route.GetRouteData(effectiveHttpContext); if (routeData == null) return null; // otherwise paint wrap handler and return it var containerProvider = new ContainerProvider(_container); routeData.RouteHandler = new RouteHandler(containerProvider, routeData.RouteHandler); routeData.DataTokens["IContainerProvider"] = containerProvider; return routeData; }
public RouteHandler(ContainerProvider containerProvider, IRouteHandler routeHandler) { _containerProvider = containerProvider; _routeHandler = routeHandler; }
public HttpHandler(ContainerProvider containerProvider, IHttpHandler httpHandler) { _containerProvider = containerProvider; _httpHandler = httpHandler; }
public HttpAsyncHandler(ContainerProvider containerProvider, IHttpAsyncHandler httpAsyncHandler) : base(containerProvider, httpAsyncHandler) { _httpAsyncHandler = httpAsyncHandler; }
protected void Application_Start() { _containerProvider = new ContainerProvider(Ioc.Wootstrapper.CreateApplicationContainer()); Mvc.Wootstrapper.Initialize(_containerProvider); }