GFramework/GFramework.Core/model/AbstractModel.cs
GeWuYou 2cfa78b91d feat(architecture): 添加架构阶段感知能力支持
- 在AbstractModel和AbstractSystem中添加OnArchitecturePhase虚方法实现
- 修改Architecture类移除IArchitectureLifecycle接口和OnPhase方法
- 更新IModel和ISystem接口继承IArchitecturePhaseAware接口
- 修改AbstractResourceFactorySystem实现IArchitecturePhaseAware接口
- 在测试类TestModel和TestSystem中添加OnArchitecturePhase方法实现
- 在项目文件中添加对生成器相关目录的排除配置
- 将ArchitecturePhase枚举引入到相关文件中
2025-12-31 12:42:06 +08:00

48 lines
1.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using GFramework.Core.Abstractions.architecture;
using GFramework.Core.Abstractions.enums;
using GFramework.Core.Abstractions.model;
namespace GFramework.Core.model;
/// <summary>
/// 抽象模型基类实现IModel接口提供模型的基本架构支持
/// </summary>
public abstract class AbstractModel : IModel
{
/// <summary>
/// 模型所属的架构实例
/// </summary>
protected IArchitectureContext _context { get; private set; }
/// <summary>
/// 初始化模型调用抽象方法OnInit执行具体初始化逻辑
/// </summary>
void IModel.Init()
{
OnInit();
}
public void SetContext(IArchitectureContext context)
{
_context = context;
}
public IArchitectureContext GetContext()
{
return _context;
}
/// <summary>
/// 处理架构阶段事件的虚拟方法
/// </summary>
/// <param name="phase">当前的架构阶段</param>
public virtual void OnArchitecturePhase(ArchitecturePhase phase)
{
}
/// <summary>
/// 抽象初始化方法,由子类实现具体的初始化逻辑
/// </summary>
protected abstract void OnInit();
}