mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 10:34:30 +08:00
- 移除了 IArchitectureRuntime 接口和 ArchitectureRuntime 类 - 在 ArchitectureContext 中添加了对 ICommandBus 和 IQueryBus 的依赖注入 - 修改 Architecture 类以使用 CommandBus 和 QueryBus 替代 Runtime - 更新 ArchitectureServices 以提供 CommandBus 和 QueryBus 服务 - 将组件初始化逻辑从 if-else 改为 switch 语句 - 更新 ContextAwareBase 以使用新的 GetFirstArchitectureContext 方法 - 添加了 CommandBus 和 QueryBus 的实现类 - 修复了 Godot 模块中系统获取的重复代码问题
58 lines
1.6 KiB
C#
58 lines
1.6 KiB
C#
using GFramework.Core.Abstractions.architecture;
|
|
using GFramework.Core.Abstractions.command;
|
|
using GFramework.Core.Abstractions.events;
|
|
using GFramework.Core.Abstractions.ioc;
|
|
using GFramework.Core.Abstractions.query;
|
|
using GFramework.Core.command;
|
|
using GFramework.Core.events;
|
|
using GFramework.Core.ioc;
|
|
using GFramework.Core.query;
|
|
|
|
namespace GFramework.Core.architecture;
|
|
|
|
/// <summary>
|
|
/// 架构服务类,提供依赖注入容器、事件系统、命令总线和查询总线等核心服务
|
|
/// </summary>
|
|
public class ArchitectureServices : IArchitectureServices
|
|
{
|
|
private IArchitectureContext _context = null!;
|
|
|
|
/// <summary>
|
|
/// 获取依赖注入容器
|
|
/// </summary>
|
|
public IIocContainer Container { get; } = new IocContainer();
|
|
|
|
/// <summary>
|
|
/// 获取类型事件系统
|
|
/// </summary>
|
|
public ITypeEventSystem TypeEventSystem { get; } = new TypeEventSystem();
|
|
|
|
/// <summary>
|
|
/// 获取命令总线
|
|
/// </summary>
|
|
public ICommandBus CommandBus { get; } = new CommandBus();
|
|
|
|
/// <summary>
|
|
/// 获取查询总线
|
|
/// </summary>
|
|
public IQueryBus QueryBus { get; } = new QueryBus();
|
|
|
|
/// <summary>
|
|
/// 设置架构上下文
|
|
/// </summary>
|
|
/// <param name="context">架构上下文对象</param>
|
|
public void SetContext(IArchitectureContext context)
|
|
{
|
|
_context = context;
|
|
Container.SetContext(context);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取架构上下文
|
|
/// </summary>
|
|
/// <returns>架构上下文对象</returns>
|
|
public IArchitectureContext GetContext()
|
|
{
|
|
return _context;
|
|
}
|
|
} |