mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-23 03:04:29 +08:00
- 将IocContainer的Init方法重命名为OnContextReady并设为protected override - 重构AbstractModel中的Architecture字段为_context属性并实现IContextAware接口 - 移除GetArchitecture和SetArchitecture方法,添加GetContext和SetContext方法 - 为IModel接口添加IContextAware继承 - 添加TestArchitecture、TestModel和TestSystem测试类 - 创建ArchitectureInitializationTests测试用例验证组件初始化 - 更新项目文件添加NUnit包引用和测试项目配置 - 在解决方案文件中添加测试项目引用
59 lines
1.3 KiB
C#
59 lines
1.3 KiB
C#
using GFramework.Core.Abstractions.architecture;
|
||
using GFramework.Core.Abstractions.system;
|
||
|
||
namespace GFramework.Core.Tests.system;
|
||
|
||
/// <summary>
|
||
/// 测试系统类,实现了ISystem接口
|
||
/// </summary>
|
||
public sealed class TestSystem : ISystem
|
||
{
|
||
/// <summary>
|
||
/// 架构上下文对象
|
||
/// </summary>
|
||
private IArchitectureContext _context = null!;
|
||
|
||
/// <summary>
|
||
/// 获取系统是否已初始化的状态
|
||
/// </summary>
|
||
public bool Inited { get; private set; }
|
||
|
||
/// <summary>
|
||
/// 获取系统是否已销毁的状态
|
||
/// </summary>
|
||
public bool Destroyed { get; private set; }
|
||
|
||
/// <summary>
|
||
/// 设置架构上下文
|
||
/// </summary>
|
||
/// <param name="context">架构上下文对象</param>
|
||
public void SetContext(IArchitectureContext context)
|
||
{
|
||
_context = context;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取架构上下文
|
||
/// </summary>
|
||
/// <returns>架构上下文对象</returns>
|
||
public IArchitectureContext GetContext()
|
||
{
|
||
return _context;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 初始化系统
|
||
/// </summary>
|
||
public void Init()
|
||
{
|
||
Inited = true;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 销毁系统
|
||
/// </summary>
|
||
public void Destroy()
|
||
{
|
||
Destroyed = true;
|
||
}
|
||
} |