/// <summary>
        /// Initialize Container
        /// </summary>
        /// 
        public static void InitializeContainer()
        {
            try
            {
                // Initialize Windsor
                IWindsorContainer container = new CuyahogaContainer();

                // Inititialize the static Windsor helper class.
                IoC.Initialize(container);

                // Add ICuyahogaContext to the container.
                container.Register(Component.For<ICuyahogaContext>()
                    .ImplementedBy<CuyahogaContext>()
                    .Named("cuyahoga.context")
                    .LifeStyle.PerWebRequest
                );

                // Add ICuyahogaContextProvider to the container.
                container.Register(Component.For<ICuyahogaContextProvider>()
                    .ImplementedBy<CuyahogaContextProvider>()
                );

                // Windsor controller builder
                //ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(container));
            }
            catch (Exception ex)
            {
                log.Error("Error initializing application.", ex);
                throw;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initialize Container
        /// </summary>
        ///
        public static void InitializeContainer()
        {
            try
            {
                // Initialize Windsor
                IWindsorContainer container = new CuyahogaContainer();

                // Inititialize the static Windsor helper class.
                IoC.Initialize(container);

                // Add ICuyahogaContext to the container.
                container.Register(Component.For <ICuyahogaContext>()
                                   .ImplementedBy <CuyahogaContext>()
                                   .Named("cuyahoga.context")
                                   .LifeStyle.PerWebRequest
                                   );

                // Add ICuyahogaContextProvider to the container.
                container.Register(Component.For <ICuyahogaContextProvider>()
                                   .ImplementedBy <CuyahogaContextProvider>()
                                   );

                // Windsor controller builder
                ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(container));

                // Register ASP.NET MVC components
                RegisterMvcComponents(container);

                // Validators
                RegisterValidatorComponents(container);

                // Localizer
                container.Register(Component.For <ILocalizer>()
                                   .ImplementedBy <GlobalResourceLocalizer>()
                                   );
            }
            catch (Exception ex)
            {
                log.Error("Error initializing application.", ex);
                throw;
            }
        }
Ejemplo n.º 3
0
        protected void Application_Start(Object sender, EventArgs e)
        {
            // Initialize Cuyahoga environment

            // Set application level flags.
            HttpContext.Current.Application.Lock();
            HttpContext.Current.Application["IsFirstRequest"] = true;
            HttpContext.Current.Application["ModulesLoaded"] = false;
            HttpContext.Current.Application["IsModuleLoading"] = false;
            HttpContext.Current.Application["IsInstalling"] = false;
            HttpContext.Current.Application["IsUpgrading"] = false;
            HttpContext.Current.Application.UnLock();

            // Initialize log4net
            XmlConfigurator.Configure();

            // Initialize Windsor
            IWindsorContainer container = new CuyahogaContainer();
            container.Kernel.ComponentCreated += new ComponentInstanceDelegate(Kernel_ComponentCreated);
            container.Kernel.ComponentDestroyed += new ComponentInstanceDelegate(Kernel_ComponentDestroyed);

            // Inititialize the static Windsor helper class.
            IoC.Initialize(container);
        }