mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 10:34:30 +08:00
- 更新所有GFramework.Core.Abstractions.System引用为GFramework.Core.Abstractions.Systems - 重命名GFramework.Core/System目录为GFramework.Core/Systems - 重命名GFramework.Core.Tests/System目录为GFramework.Core.Tests/Systems - 更新所有相关using语句和命名空间声明 - 修复测试文件中的命名空间引用 - 添加全局using引用GFramework.Core.Systems
62 lines
1.6 KiB
C#
62 lines
1.6 KiB
C#
using GFramework.Core.Abstractions.Enums;
|
|
using GFramework.Core.Abstractions.Logging;
|
|
using GFramework.Core.Abstractions.Systems;
|
|
using GFramework.Core.Logging;
|
|
using GFramework.Core.Rule;
|
|
|
|
namespace GFramework.Core.Systems;
|
|
|
|
/// <summary>
|
|
/// 抽象系统基类,实现系统接口的基本功能
|
|
/// 提供架构关联、初始化和销毁机制
|
|
/// </summary>
|
|
public abstract class AbstractSystem : ContextAwareBase, ISystem
|
|
{
|
|
private ILogger _logger = null!;
|
|
|
|
/// <summary>
|
|
/// 系统初始化方法,调用抽象初始化方法
|
|
/// </summary>
|
|
public void Initialize()
|
|
{
|
|
var name = GetType().Name;
|
|
_logger = LoggerFactoryResolver.Provider.CreateLogger(name);
|
|
_logger.Debug($"Initializing system: {name}");
|
|
|
|
OnInit();
|
|
|
|
_logger.Info($"System initialized: {name}");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 系统销毁方法,调用抽象销毁方法
|
|
/// </summary>
|
|
public void Destroy()
|
|
{
|
|
_logger.Debug($"Destroying system: {GetType().Name}");
|
|
|
|
OnDestroy();
|
|
|
|
_logger.Info($"System destroyed: {GetType().Name}");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 处理架构阶段事件的虚拟方法
|
|
/// </summary>
|
|
/// <param name="phase">当前的架构阶段</param>
|
|
public virtual void OnArchitecturePhase(ArchitecturePhase phase)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// 抽象初始化方法,由子类实现具体的初始化逻辑
|
|
/// </summary>
|
|
protected abstract void OnInit();
|
|
|
|
/// <summary>
|
|
/// 抽象销毁方法,由子类实现具体的资源清理逻辑
|
|
/// </summary>
|
|
protected virtual void OnDestroy()
|
|
{
|
|
}
|
|
} |