/// <summary>
        /// Method to run logic before application start (as PreApplicationStartMethod). Do not run this method from your code.
        /// </summary>
        public static void PreApplicationStart()
        {
            ILog logger;

            try
            {
                logger = LogManager.GetCurrentClassLogger();
                logger.Info("Starting Better CMS...");
            }
            catch (Exception ex)
            {
                throw new CoreException("Logging is not working. A reason may be that Common.Logging section is not configured in web.config.", ex);
            }

            if (!IsFullTrust)
            {
                string message = "Application should run under FullTrust .NET trust level.";
                logger.Fatal(message);

                throw new CmsException(message);
            }

            try
            {
                logger.Info("Creating Better CMS context dependencies container...");
                ContextScopeProvider.RegisterTypes(CmsContext.InitializeContainer());
            }
            catch (Exception ex)
            {
                string message = "Failed to create Better CMS context dependencies container.";
                logger.Fatal(message, ex);

                throw new CmsException(message, ex);
            }

            try
            {
                logger.Info("Registering forms authentication redirect suppress module...");
                SuppressFormsAuthenticationRedirectModule.DynamicModuleRegistration();
            }
            catch (Exception ex)
            {
                string message = "Failed to register forms authentication redirect suppress module.";
                logger.Fatal(message, ex);

                throw new CmsException(message, ex);
            }
        }
예제 #2
0
        private static ILifetimeScope CreateContainer()
        {
            ContainerBuilder updater = CmsContext.InitializeContainer();

            updater.RegisterType <StubMappingResolver>().As <IMappingResolver>();
            ContextScopeProvider.RegisterTypes(updater);

            var container = ContextScopeProvider.CreateChildContainer();

            IModulesRegistration modulesRegistration = container.Resolve <IModulesRegistration>();

            foreach (var knownAssembly in KnownAssemblies)
            {
                modulesRegistration.AddModuleDescriptorTypeFromAssembly(knownAssembly);
            }
            modulesRegistration.InitializeModules();

            return(container);
        }
예제 #3
0
        /// <summary>
        /// Method to run logic before application start (as PreApplicationStartMethod). Do not run this method from your code.
        /// </summary>
        public static void PreApplicationStart()
        {
            ILog logger;

            try
            {
                logger = LogManager.GetCurrentClassLogger();
                logger.Info("Starting Better CMS...");
            }
            catch (Exception ex)
            {
                throw new CmsException("Logging is not working. A reason may be that Common.Logging section is not configured in web.config.", ex);
            }

            if (!IsFullTrust)
            {
                string message = "Application should run under FullTrust .NET trust level.";
                logger.Fatal(message);

                throw new CmsException(message);
            }

            try
            {
                logger.Info("Creating Better CMS context dependencies container...");
                ContextScopeProvider.RegisterTypes(CmsContext.InitializeContainer());
            }
            catch (Exception ex)
            {
                string message = "Failed to create Better CMS context dependencies container.";
                logger.Fatal(message, ex);

                throw new CmsException(message, ex);
            }

            try
            {
                logger.Info("Registering per web request lifetime manager module...");
                PerWebRequestLifetimeModule.DynamicModuleRegistration();
            }
            catch (Exception ex)
            {
                string message = "Failed to register per web request lifetime manager module.";
                logger.Fatal(message, ex);

                throw new CmsException(message, ex);
            }

            try
            {
                logger.Info("Load assemblies...");
                CmsContext.LoadAssemblies();
            }
            catch (Exception ex)
            {
                string message = "Failed to load assemblies.";
                logger.Fatal(message, ex);

                throw new CmsException(message, ex);
            }

            try
            {
                // TODO: implement
            }
            catch (Exception ex)
            {
                string message = "Failed to initialize role provider.";
                logger.Fatal(message, ex);

                throw new CmsException(message, ex);
            }
        }