mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-23 03:04:29 +08:00
- 将架构服务重构为模块化设计,引入ServiceModuleManager统一管理 - 新增EventBusModule、CommandExecutorModule、QueryExecutorModule等核心服务模块 - 实现ECS模块支持,可配置启用Entity Component System功能 - 在架构初始化过程中集成模块注册、初始化和销毁流程 - 更新架构属性配置,添加EnableEcs开关控制ECS功能启用 - 优化服务获取方式,从直接依赖改为通过容器动态获取 - 移除架构上下文中的ECS相关实现代码,统一由ECS模块管理
55 lines
1.7 KiB
C#
55 lines
1.7 KiB
C#
using GFramework.Core.Abstractions.architecture;
|
|
using GFramework.Core.Abstractions.ioc;
|
|
using GFramework.Core.events;
|
|
|
|
namespace GFramework.Core.services.modules;
|
|
|
|
/// <summary>
|
|
/// 事件总线模块,用于注册和管理事件总线服务。
|
|
/// 该模块负责将事件总线注册到依赖注入容器中,并提供初始化和销毁功能。
|
|
/// </summary>
|
|
public sealed class EventBusModule : IServiceModule
|
|
{
|
|
/// <summary>
|
|
/// 获取模块名称。
|
|
/// </summary>
|
|
public string ModuleName => nameof(EventBusModule);
|
|
|
|
/// <summary>
|
|
/// 获取模块优先级,数值越小优先级越高。
|
|
/// </summary>
|
|
public int Priority => 10;
|
|
|
|
/// <summary>
|
|
/// 获取模块启用状态,始终返回 true 表示该模块默认启用。
|
|
/// </summary>
|
|
public bool IsEnabled => true;
|
|
|
|
/// <summary>
|
|
/// 注册事件总线到依赖注入容器。
|
|
/// 创建事件总线实例并将其注册为多例服务。
|
|
/// </summary>
|
|
/// <param name="container">依赖注入容器实例。</param>
|
|
public void Register(IIocContainer container)
|
|
{
|
|
container.RegisterPlurality(new EventBus());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 初始化模块。
|
|
/// 当前实现为空,因为事件总线无需额外初始化逻辑。
|
|
/// </summary>
|
|
public void Initialize()
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// 异步销毁模块。
|
|
/// 当前实现为空,因为事件总线无需特殊销毁逻辑。
|
|
/// </summary>
|
|
/// <returns>表示异步操作完成的任务。</returns>
|
|
public ValueTask DestroyAsync()
|
|
{
|
|
return ValueTask.CompletedTask;
|
|
}
|
|
} |