/// <summary> /// 应用模块服务,仅在AspNetCore环境下调用,非AspNetCore环境请执行<see cref="UseModule(IServiceProvider)"/>功能 /// </summary> /// <param name="app">应用程序构建器</param> public void UseModule(IApplicationBuilder app) { ILogger logger = app.ApplicationServices.GetLogger <AspHybridModuleManager>(); logger.LogInformation("Hybrid框架初始化开始"); DateTime dtStart = DateTime.Now; foreach (HybridModule module in LoadedModules) { if (module is AspHybridModule aspModule) { aspModule.UseModule(app); } else { module.UseModule(app.ApplicationServices); } } IServiceProvider provider = app.ApplicationServices; ILocalizationManager localizationManager = provider.GetRequiredService <ILocalizationManager>(); localizationManager.Initialize(); TimeSpan ts = DateTime.Now.Subtract(dtStart); logger.LogInformation($"Hybrid框架初始化完成,耗时:{ts:g}"); }
/// <summary> /// 应用模块服务 /// </summary> /// <param name="provider">服务提供者</param> public virtual void UseModule(IServiceProvider provider) { ILogger logger = provider.GetLogger <HybridModuleManager>(); logger.LogInformation("Hybrid框架初始化开始"); Stopwatch watch = Stopwatch.StartNew(); foreach (HybridModule module in LoadedModules) { module.UseModule(provider); logger.LogInformation($"模块{module.GetType()}加载成功"); } ILocalizationManager localizationManager = provider.GetRequiredService <ILocalizationManager>(); localizationManager.Initialize(); watch.Stop(); logger.LogInformation($"Hybrid框架初始化完成,耗时:{watch.Elapsed}"); }
public override void Execute() { _localizationManager.Initialize(_settingsContainer.Settings.Language); }