using GWFramework.framework.events;
namespace GWFramework.framework.extensions;
///
/// 事件注册扩展类,提供ICanRegisterEvent接口的扩展方法用于注册和注销事件
///
public static class CanRegisterEventExtensions
{
///
/// 注册指定类型的事件处理函数
///
/// 事件数据类型
/// 实现ICanRegisterEvent接口的对象实例
/// 事件处理回调函数
/// 返回事件注销器接口,可用于后续注销事件
public static IUnRegister RegisterEvent(this ICanRegisterEvent self, Action onEvent) =>
self.GetArchitecture().RegisterEvent(onEvent);
///
/// 注销指定类型的事件处理函数
///
/// 事件数据类型
/// 实现ICanRegisterEvent接口的对象实例
/// 要注销的事件处理回调函数
public static void UnRegisterEvent(this ICanRegisterEvent self, Action onEvent) =>
self.GetArchitecture().UnRegisterEvent(onEvent);
}