mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-25 13:33:28 +08:00
feat(events): 添加全局事件获取或添加功能
- 实现了GetOrAdd方法用于获取或添加指定类型的全局事件 - 添加了XML文档注释说明方法用途和泛型约束 - 方法支持自动创建不存在的事件实例并返回指定类型对象
This commit is contained in:
parent
2ae26ea590
commit
6cfde41dc6
@ -1,4 +1,4 @@
|
|||||||
using GFramework.Core.Abstractions.events;
|
using GFramework.Core.Abstractions.events;
|
||||||
|
|
||||||
namespace GFramework.Core.events;
|
namespace GFramework.Core.events;
|
||||||
|
|
||||||
@ -37,6 +37,16 @@ public class EasyEvents
|
|||||||
MGlobalEvents.AddEvent<T>();
|
MGlobalEvents.AddEvent<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或添加指定类型的全局事件
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">事件类型,必须实现IEasyEvent接口且具有无参构造函数</typeparam>
|
||||||
|
/// <returns>指定类型的事件实例</returns>
|
||||||
|
public static T GetOrAdd<T>() where T : IEvent, new()
|
||||||
|
{
|
||||||
|
return MGlobalEvents.GetOrAddEvent<T>();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加指定类型的事件到事件字典中
|
/// 添加指定类型的事件到事件字典中
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user