コード例 #1
0
        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);
        }
コード例 #2
0
        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));
        }
コード例 #3
0
ファイル: Global.asax.cs プロジェクト: BjartN/Blog
        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);
        }
コード例 #4
0
ファイル: Global.asax.cs プロジェクト: ryansull/TankMapper
        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));
        }
コード例 #5
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            var container = ConfigureAutofacContainer();
            _containterProvider = new ContainerProvider(container);

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
ファイル: ShellRoute.cs プロジェクト: mofashi2011/orchardcms
        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;
        }
コード例 #9
0
ファイル: ShellRoute.cs プロジェクト: mofashi2011/orchardcms
 public RouteHandler(ContainerProvider containerProvider, IRouteHandler routeHandler)
 {
     _containerProvider = containerProvider;
     _routeHandler = routeHandler;
 }
コード例 #10
0
ファイル: ShellRoute.cs プロジェクト: mofashi2011/orchardcms
 public HttpHandler(ContainerProvider containerProvider, IHttpHandler httpHandler)
 {
     _containerProvider = containerProvider;
     _httpHandler = httpHandler;
 }
コード例 #11
0
ファイル: ShellRoute.cs プロジェクト: mofashi2011/orchardcms
 public HttpAsyncHandler(ContainerProvider containerProvider, IHttpAsyncHandler httpAsyncHandler)
     : base(containerProvider, httpAsyncHandler)
 {
     _httpAsyncHandler = httpAsyncHandler;
 }
コード例 #12
0
 protected void Application_Start()
 {
     _containerProvider = new ContainerProvider(Ioc.Wootstrapper.CreateApplicationContainer());
     Mvc.Wootstrapper.Initialize(_containerProvider);
 }