mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 10:34:30 +08:00
- 创建了 AbstractContextUtility 抽象类,继承 ContextAwareBase 并实现 IContextUtility 接口 - 实现了 IContextUtility 接口,提供上下文相关的通用功能 - 添加了 Init 方法用于初始化上下文工具,包含日志记录功能 - 提供了抽象 OnInit 方法供子类实现具体初始化逻辑 - 定义了 IContextUtility 接口,继承 IUtility 和 IContextAware 接口 - 添加了上下文感知能力的工具功能支持
35 lines
997 B
C#
35 lines
997 B
C#
using GFramework.Core.logging;
|
|
using GFramework.Core.rule;
|
|
|
|
namespace GFramework.Core.utility;
|
|
|
|
/// <summary>
|
|
/// 抽象上下文工具类,提供上下文相关的通用功能实现
|
|
/// 继承自ContextAwareBase并实现IContextUtility接口
|
|
/// </summary>
|
|
public abstract class AbstractContextUtility : ContextAwareBase, IContextUtility
|
|
{
|
|
private ILogger _logger = null!;
|
|
|
|
/// <summary>
|
|
/// 初始化上下文工具类
|
|
/// </summary>
|
|
void IContextUtility.Init()
|
|
{
|
|
// 获取上下文中的日志记录器
|
|
_logger = Context.Logger;
|
|
_logger.Debug($"Initializing Context Utility: {GetType().Name}");
|
|
|
|
// 执行子类实现的初始化逻辑
|
|
OnInit();
|
|
|
|
// 记录初始化完成信息
|
|
_logger.Info($"Context Utility initialized: {GetType().Name}");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 抽象初始化方法,由子类实现具体的初始化逻辑
|
|
/// </summary>
|
|
protected abstract void OnInit();
|
|
}
|