mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 19:03:29 +08:00
- 移除 ArchitectureContext 构造函数中的 ILogger 参数 - 从 IArchitectureContext 接口中移除 Logger 属性 - 更新 AbstractContextUtility 使用 LoggerFactory 创建日志记录器 - 修改 AbstractSystem 使用 LoggerFactory 获取日志记录器 - 调整 Architecture 类中上下文创建时的日志工厂使用 - 更新 IocContainer 初始化时的日志记录器获取方式 - 移除 IIocContainer 接口中的 Init 方法定义 - [no tag]
50 lines
1.3 KiB
C#
50 lines
1.3 KiB
C#
using GFramework.Core.logging;
|
|
using GFramework.Core.rule;
|
|
|
|
namespace GFramework.Core.system;
|
|
|
|
/// <summary>
|
|
/// 抽象系统基类,实现系统接口的基本功能
|
|
/// 提供架构关联、初始化和销毁机制
|
|
/// </summary>
|
|
public abstract class AbstractSystem : ContextAwareBase, ISystem
|
|
{
|
|
private ILogger _logger = null!;
|
|
|
|
/// <summary>
|
|
/// 系统初始化方法,调用抽象初始化方法
|
|
/// </summary>
|
|
void ISystem.Init()
|
|
{
|
|
_logger = Context.LoggerFactory.GetLogger(nameof(AbstractSystem));
|
|
_logger.Debug($"Initializing system: {GetType().Name}");
|
|
|
|
OnInit();
|
|
|
|
_logger.Info($"System initialized: {GetType().Name}");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 系统销毁方法,调用抽象销毁方法
|
|
/// </summary>
|
|
void ISystem.Destroy()
|
|
{
|
|
_logger.Debug($"Destroying system: {GetType().Name}");
|
|
|
|
OnDestroy();
|
|
|
|
_logger.Info($"System destroyed: {GetType().Name}");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 抽象初始化方法,由子类实现具体的初始化逻辑
|
|
/// </summary>
|
|
protected abstract void OnInit();
|
|
|
|
/// <summary>
|
|
/// 抽象销毁方法,由子类实现具体的资源清理逻辑
|
|
/// </summary>
|
|
protected virtual void OnDestroy()
|
|
{
|
|
}
|
|
} |