コード例 #1
0
        public void Tilgangskontroll()
        {
            var container = new WindsorContainer();

            container.Install(new DependencyConventions());

            var controllerFactory    = new WindsorMvcControllerFactory(container);
            var apiControllerFactory = new WindsorControllerActivator(container);

            //var t1 = ServiceLocator.Current.Resolve<TilgangsKontroll>();
            //var t2 = controllerFactory.CreateController()
        }
コード例 #2
0
ファイル: Global.asax.cs プロジェクト: admgalloway/ajs
        /// <summary>Setup our IoC container and register a custom controllerFactory to use it
        /// </summary>
        private void SetupIoC(HttpConfiguration config)
        {
            // setup a windsor container using any installers declared in this assembly
            container = new WeeWorldWindsorContainer();

            // replace default Controller Factory with dedicated WeeWorld one (for MVC Controllers)
            //var controllerFactory = new WindsorControllerFactory(container.Kernel);
            //ControllerBuilder.Current.SetControllerFactory(controllerFactory);

            // replace default Controller Activator with dedicated WeeWorld one (for API controllers)
            var controllerActivator = new WindsorControllerActivator(container);

            config.Services.Replace(typeof(IHttpControllerActivator), controllerActivator);
        }
コード例 #3
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            // Setup DocumentDB schema.
            DocumentDbConfig.Initialize();
            // Setup IoC container for ApiControllers.
            container = new WindsorContainer().Install(FromAssembly.This());
            WindsorControllerActivator activator = new WindsorControllerActivator(container.Kernel);

            GlobalConfiguration.Configuration.Services.Replace(typeof(IHttpControllerActivator), activator);
        }
コード例 #4
0
        public static void Config(IWindsorContainer container, HttpConfiguration config)
        {
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }
            container.Install(new CastleConfig());

            IHttpControllerActivator controllerFactory = new WindsorControllerActivator(container);

            if (config != null)
            {
                config.Services.Replace(typeof(IHttpControllerActivator), controllerFactory);

                var dependencyResolver = new WindsorDependencyResolver(container);
                config.DependencyResolver = dependencyResolver;
            }
        }
コード例 #5
0
ファイル: Global.asax.cs プロジェクト: taneltumanski/Zoo
        protected void Application_Start()
        {
            Cfg.AppSettings.Init <IConfig>();

            System.Data.Entity.Database.SetInitializer(new CustomDatabaseInitializer());

            Container = new WindsorContainer().Install(FromAssembly.This());

            // custom controllerfactory
            ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(Container.Kernel));

            var controllerActivator = new WindsorControllerActivator(Container.Kernel);

            // Replace default API controller activator with custom one
            GlobalConfiguration.Configuration.Services.Replace(typeof(IHttpControllerActivator), controllerActivator);

            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(x => WebApiConfig.Register(x, Container));
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }