mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 10:34:30 +08:00
- 将TypeEventSystem重命名为EventBus - 将IEasyEvent接口重命名为IEvent接口 - 将ITypeEventSystem接口重命名为IEventBus接口 - 更新Architecture类中使用TypeEventSystem为EventBus - 更新ArchitectureContext中依赖注入参数类型 - 将EasyEvent泛型类重命名为Event泛型类 - 更新所有相关类型引用和实现 - 修改接口继承关系以使用新的事件接口命名
37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using System;
|
|
|
|
namespace GFramework.Core.Abstractions.events;
|
|
|
|
/// <summary>
|
|
/// 事件总线接口,提供事件的发送、注册和注销功能
|
|
/// </summary>
|
|
public interface IEventBus
|
|
{
|
|
/// <summary>
|
|
/// 发送事件,自动创建事件实例
|
|
/// </summary>
|
|
/// <typeparam name="T">事件类型,必须具有无参构造函数</typeparam>
|
|
void Send<T>() where T : new();
|
|
|
|
/// <summary>
|
|
/// 发送指定的事件实例
|
|
/// </summary>
|
|
/// <typeparam name="T">事件类型</typeparam>
|
|
/// <param name="e">事件实例</param>
|
|
void Send<T>(T e);
|
|
|
|
/// <summary>
|
|
/// 注册事件监听器
|
|
/// </summary>
|
|
/// <typeparam name="T">事件类型</typeparam>
|
|
/// <param name="onEvent">事件处理回调函数</param>
|
|
/// <returns>反注册接口,用于注销事件监听</returns>
|
|
IUnRegister Register<T>(Action<T> onEvent);
|
|
|
|
/// <summary>
|
|
/// 注销事件监听器
|
|
/// </summary>
|
|
/// <typeparam name="T">事件类型</typeparam>
|
|
/// <param name="onEvent">要注销的事件处理回调函数</param>
|
|
void UnRegister<T>(Action<T> onEvent);
|
|
} |