Exemple #1
0
        /// <summary>
        /// Intialize main application
        /// </summary>
        /// <param name="websiteRootDirectory">Website root directory</param>
        public static void Initialize(string websiteRootDirectory)
        {
            // Throw exception if already initialized
            if (Interlocked.Exchange(ref initialized, 1) != 0)
            {
                throw new InvalidOperationException("Application already initialized");
            }
            // Register core components
            Ioc.RegisterMany <CacheFactory>(ReuseType.Singleton);
            Ioc.RegisterMany <DatabaseManager>(ReuseType.Singleton);
            Ioc.RegisterMany <TJsonConverter>(ReuseType.Singleton);
            Ioc.RegisterMany <TranslateManager>(ReuseType.Singleton);
            Ioc.RegisterMany <LogManager>(ReuseType.Singleton);
#if NETCORE
            Ioc.RegisterMany <CoreAssemblyLoader>(ReuseType.Singleton);
#else
            Ioc.RegisterMany <NetAssemblyLoader>(ReuseType.Singleton);
#endif
            Ioc.RegisterMany <RoslynCompilerService>(ReuseType.Singleton);
            Ioc.RegisterMany <PluginManager>(ReuseType.Singleton);
#pragma warning disable CS0618
            Ioc.RegisterMany <ConfigManager>(ReuseType.Singleton);
            Ioc.RegisterMany <PathConfig>(ReuseType.Singleton);
            Ioc.RegisterMany <PathManager>(ReuseType.Singleton);
#pragma warning restore CS0618
            Ioc.RegisterMany <WebsiteConfigManager>(ReuseType.Singleton);
            Ioc.RegisterMany <LocalFileStorage>(ReuseType.Singleton);
            Ioc.RegisterMany <LocalPathConfig>(ReuseType.Singleton);
            Ioc.RegisterMany <LocalPathManager>(ReuseType.Singleton);
            Ioc.RegisterMany <TemplateAreaManager>(ReuseType.Singleton);
            Ioc.RegisterMany <TemplateWidgetRenderer>(ReuseType.Singleton);
            Ioc.RegisterMany <TemplateFileSystem>(ReuseType.Singleton);
            Ioc.RegisterMany <TemplateManager>(ReuseType.Singleton);
            Ioc.RegisterMany <TestManager>(ReuseType.Singleton);
            Ioc.RegisterMany <AddVersionHeaderHandler>(ReuseType.Singleton);
            Ioc.RegisterMany <DefaultErrorHandler>(ReuseType.Singleton);
            Ioc.RegisterMany <ControllerManager>(ReuseType.Singleton);
            Ioc.RegisterMany <CacheIsolateByDevice>(ReuseType.Singleton, serviceKey: "Device");
            Ioc.RegisterMany <CacheIsolateByLocale>(ReuseType.Singleton, serviceKey: "Locale");
            Ioc.RegisterMany <CacheIsolateByUrl>(ReuseType.Singleton, serviceKey: "Url");
            // Initialize core components
            LocalPathConfig.Initialize(websiteRootDirectory);
            WebsiteConfigManager.Initialize();
            PluginManager.Initialize();
            JsonNetInitializer.Initialize();
            TemplateManager.Initialize();
            ThreadPoolInitializer.Initialize();
            DatabaseManager.Initialize();
            // Initialize all plugins and controllers
            Ioc.ResolveMany <IPlugin>().ForEach(p => { });
            ControllerManager.Initialize();
            Ioc.ResolveMany <IWebsiteStartHandler>().ForEach(h => h.OnWebsiteStart());
            // Start the resident core processes
            PluginReloader.Start();
            AutomaticCacheCleaner.Start();
        }
Exemple #2
0
 /// <summary>
 /// Initialize core components
 /// </summary>
 protected virtual void InitializeCoreComponents()
 {
     LocalPathConfig.Initialize(WebsiteRootDirectory);
     WebsiteConfigManager.Initialize();
     PluginManager.Initialize();
     JsonNetInitializer.Initialize();
     TemplateManager.Initialize();
     ThreadPoolInitializer.Initialize();
     DatabaseManager.Initialize();
 }