将Feature/XP.Common和Feature/XP.Hardware分支合并至Develop/XP.forHardwareAndCommon,完善XPapp注册和相关硬件类库通用类库功能。
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using Prism.Ioc;
|
||||
using Prism.Modularity;
|
||||
using XP.Common.Dump.Configs;
|
||||
using XP.Common.Dump.Implementations;
|
||||
using XP.Common.Dump.Interfaces;
|
||||
using XP.Common.Helpers;
|
||||
using XP.Common.Localization.Configs;
|
||||
using XP.Common.Localization.Extensions;
|
||||
using XP.Common.Localization.Implementations;
|
||||
using XP.Common.Localization.Interfaces;
|
||||
using XP.Common.Logging.Interfaces;
|
||||
using XP.Common.PdfViewer.Implementations;
|
||||
using XP.Common.PdfViewer.Interfaces;
|
||||
|
||||
namespace XP.Common.Module
|
||||
{
|
||||
/// <summary>
|
||||
/// 通用模块 | Common module
|
||||
/// 提供通用基础设施服务,包括本地化支持 | Provides common infrastructure services including localization support
|
||||
/// </summary>
|
||||
public class CommonModule : IModule
|
||||
{
|
||||
/// <summary>
|
||||
/// 模块初始化 | Module initialization
|
||||
/// 在所有类型注册完成后调用 | Called after all types are registered
|
||||
/// </summary>
|
||||
public void OnInitialized(IContainerProvider containerProvider)
|
||||
{
|
||||
// 获取日志服务 | Get logger service
|
||||
var logger = containerProvider.Resolve<ILoggerService>().ForModule("XP.Common.Module.CommonModule");
|
||||
|
||||
try
|
||||
{
|
||||
// 解析本地化服务 | Resolve localization service
|
||||
var localizationService = containerProvider.Resolve<ILocalizationService>();
|
||||
|
||||
// 初始化 LocalizationExtension | Initialize LocalizationExtension
|
||||
LocalizationExtension.Initialize(localizationService);
|
||||
|
||||
logger.Info("本地化系统初始化成功 | Localization system initialized successfully");
|
||||
logger.Info($"当前语言 | Current language: {localizationService.CurrentLanguage}");
|
||||
|
||||
// 启动 Dump 服务 | Start Dump service
|
||||
var dumpService = containerProvider.Resolve<IDumpService>();
|
||||
dumpService.Start();
|
||||
logger.Info("Dump 服务初始化成功 | Dump service initialized successfully");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex, "本地化系统初始化失败 | Localization system initialization failed");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 注册类型到 DI 容器 | Register types to DI container
|
||||
/// </summary>
|
||||
public void RegisterTypes(IContainerRegistry containerRegistry)
|
||||
{
|
||||
// 注册本地化配置服务为单例 | Register localization config service as singleton
|
||||
containerRegistry.RegisterSingleton<ILocalizationConfig, LocalizationConfig>();
|
||||
|
||||
// 注册本地化服务为单例 | Register localization service as singleton
|
||||
containerRegistry.RegisterSingleton<ILocalizationService, ResxLocalizationService>();
|
||||
|
||||
// 注册 Dump 配置为单例(通过工厂方法加载)| Register Dump config as singleton (via factory method)
|
||||
containerRegistry.RegisterSingleton<DumpConfig>(() => ConfigLoader.LoadDumpConfig());
|
||||
|
||||
// 注册 Dump 服务为单例 | Register Dump service as singleton
|
||||
containerRegistry.RegisterSingleton<IDumpService, DumpService>();
|
||||
|
||||
// 注册 PDF 打印服务为单例 | Register PDF print service as singleton
|
||||
containerRegistry.RegisterSingleton<IPdfPrintService, PdfPrintService>();
|
||||
|
||||
// 注册 PDF 查看服务为单例 | Register PDF viewer service as singleton
|
||||
containerRegistry.RegisterSingleton<IPdfViewerService, PdfViewerService>();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user