Example #1
0
        public void Init()
        {
            container = new WindsorContainer();
            Container.Register(Component.For <IWindsorContainer>().Instance(Container));

            ContainerManager.Container = Container;

            var preActiation = new PreActivation(Container);

            preActiation.Init();

            var activator = new ModuleActivator();

            activator.RegisterComponents(Container);

            var migrator       = Container.Resolve <IMigrator>();
            var needMigrations = migrator.GetMigrations();

            if (needMigrations.Any())
            {
                migrator.Migrate();
            }
            else
            {
            }
        }
Example #2
0
        protected void Application_Start()
        {
            State = ApplicationState.Initialize;

            Container = new WindsorContainer();
            Container.Register(Component.For <IWindsorContainer>().Instance(Container));

            ContainerManager.Container = Container;

            var preActiation = new PreActivation(Container);

            preActiation.Init();

            var activator = new ModuleActivator();

            activator.RegisterComponents(Container);

            Logger = Container.Resolve <Logging.Interfaces.ILogger>();

            DependencyResolver.SetResolver(new WindsorDependencyResolver(Container));
            ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(Container.Kernel));

            var filterContainers = Container.ResolveAll <IFilterContainer>();

            foreach (var filterContainer in filterContainers)
            {
                filterContainer.Init(GlobalFilters.Filters);
            }

            var routeContainers = Container.ResolveAll <IRouteContainer>();

            foreach (var routeContainer in routeContainers)
            {
                routeContainer.Init(RouteTable.Routes);
            }

            var boundleContainers = Container.ResolveAll <IBoundleContainer>();

            foreach (var boundleContainer in boundleContainers)
            {
                boundleContainer.Init(BundleTable.Bundles);
            }

            ///TODO: добавить режим обслуживания
            var migrator = Container.Resolve <IMigrator>();

            try
            {
                var needMigrations = migrator.GetMigrations();

                if (needMigrations.Any())
                {
                    migrator.Migrate();
                }
            }
            catch (Exception e)
            {
                State = ApplicationState.Error;

                throw;
            }

            State = ApplicationState.Started;
        }