From 6cfde41dc6e0257b432f2bffc1c1ed17ec3a949e Mon Sep 17 00:00:00 2001 From: GeWuYou <95328647+GeWuYou@users.noreply.github.com> Date: Thu, 15 Jan 2026 22:00:32 +0800 Subject: [PATCH] =?UTF-8?q?feat(events):=20=E6=B7=BB=E5=8A=A0=E5=85=A8?= =?UTF-8?q?=E5=B1=80=E4=BA=8B=E4=BB=B6=E8=8E=B7=E5=8F=96=E6=88=96=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 实现了GetOrAdd方法用于获取或添加指定类型的全局事件 - 添加了XML文档注释说明方法用途和泛型约束 - 方法支持自动创建不存在的事件实例并返回指定类型对象 --- GFramework.Core/events/EasyEvents.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/GFramework.Core/events/EasyEvents.cs b/GFramework.Core/events/EasyEvents.cs index 6943320..b4d729f 100644 --- a/GFramework.Core/events/EasyEvents.cs +++ b/GFramework.Core/events/EasyEvents.cs @@ -1,4 +1,4 @@ -using GFramework.Core.Abstractions.events; +using GFramework.Core.Abstractions.events; namespace GFramework.Core.events; @@ -37,6 +37,16 @@ public class EasyEvents MGlobalEvents.AddEvent(); } + /// + /// 获取或添加指定类型的全局事件 + /// + /// 事件类型,必须实现IEasyEvent接口且具有无参构造函数 + /// 指定类型的事件实例 + public static T GetOrAdd() where T : IEvent, new() + { + return MGlobalEvents.GetOrAddEvent(); + } + /// /// 添加指定类型的事件到事件字典中 ///