mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 10:34:30 +08:00
- 移除多余using语句和空行,统一代码缩进格式 - 优化注释文档中的缩进和对齐格式 - 简化条件语句和方法实现,提升代码可读性 - 重构协程系统相关类的字段和方法定义格式 - 更新架构服务中容器访问方式的实现 - 调整异步操作类的属性和方法组织结构 - [skip ci]
104 lines
2.8 KiB
C#
104 lines
2.8 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;
|
|
using IAsyncQueryBus = GFramework.Core.Abstractions.query.IAsyncQueryBus;
|
|
|
|
namespace GFramework.Core.architecture;
|
|
|
|
/// <summary>
|
|
/// 架构服务类,提供依赖注入容器、事件系统、命令总线和查询总线等核心服务
|
|
/// </summary>
|
|
public class ArchitectureServices : IArchitectureServices
|
|
{
|
|
/// <summary>
|
|
/// 异步查询总线实例
|
|
/// </summary>
|
|
private readonly IAsyncQueryBus _asyncQueryBus;
|
|
|
|
/// <summary>
|
|
/// 命令总线实例
|
|
/// </summary>
|
|
private readonly ICommandBus _commandBus;
|
|
|
|
/// <summary>
|
|
/// 事件总线实例
|
|
/// </summary>
|
|
private readonly IEventBus _eventBus;
|
|
|
|
/// <summary>
|
|
/// 查询总线实例
|
|
/// </summary>
|
|
private readonly IQueryBus _queryBus;
|
|
|
|
private IArchitectureContext _context = null!;
|
|
|
|
/// <summary>
|
|
/// 构造函数,初始化架构服务
|
|
/// </summary>
|
|
public ArchitectureServices()
|
|
{
|
|
Container = new IocContainer();
|
|
|
|
// 创建服务实例
|
|
_eventBus = new EventBus();
|
|
_commandBus = new CommandBus();
|
|
_queryBus = new QueryBus();
|
|
_asyncQueryBus = new AsyncQueryBus();
|
|
|
|
// 将服务注册到容器
|
|
Container.RegisterPlurality(_eventBus);
|
|
Container.RegisterPlurality(_commandBus);
|
|
Container.RegisterPlurality(_queryBus);
|
|
Container.RegisterPlurality(_asyncQueryBus);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取依赖注入容器
|
|
/// </summary>
|
|
public IIocContainer Container { get; }
|
|
|
|
/// <summary>
|
|
/// 获取类型事件系统
|
|
/// </summary>
|
|
public IEventBus EventBus => _eventBus;
|
|
|
|
/// <summary>
|
|
/// 获取命令总线
|
|
/// </summary>
|
|
public ICommandBus CommandBus => _commandBus;
|
|
|
|
/// <summary>
|
|
/// 获取查询总线
|
|
/// </summary>
|
|
public IQueryBus QueryBus => _queryBus;
|
|
|
|
/// <summary>
|
|
/// 获取异步查询总线
|
|
/// </summary>
|
|
public IAsyncQueryBus AsyncQueryBus => _asyncQueryBus;
|
|
|
|
/// <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;
|
|
}
|
|
} |