gewuyou ff553977e3 chore(license): 补齐 Apache-2.0 文件头治理
- 新增许可证文件头检查与修复脚本

- 补充维护者手动修复 PR 工作流和 CI 校验

- 更新贡献指南中的文件头说明

- 补齐仓库维护源码和配置文件的许可证声明
2026-05-03 19:39:49 +08:00

42 lines
1.1 KiB
C#

// Copyright (c) 2025-2026 GeWuYou
// SPDX-License-Identifier: Apache-2.0
using GFramework.Core.Abstractions.Events;
namespace GFramework.Core.Events;
/// <summary>
/// 简单事件类,用于注册、注销和触发无参事件回调
/// </summary>
public class EasyEvent
{
private Action? _mOnEvent = () => { };
/// <summary>
/// 注册事件回调函数
/// </summary>
/// <param name="onEvent">要注册的事件回调函数</param>
/// <returns>用于注销事件的 unregister 对象</returns>
public IUnRegister Register(Action onEvent)
{
_mOnEvent += onEvent;
return new DefaultUnRegister(() => UnRegister(onEvent));
}
/// <summary>
/// 注销已注册的事件回调函数
/// </summary>
/// <param name="onEvent">要注销的事件回调函数</param>
public void UnRegister(Action onEvent)
{
_mOnEvent -= onEvent;
}
/// <summary>
/// 触发所有已注册的事件回调函数
/// </summary>
public void Trigger()
{
_mOnEvent?.Invoke();
}
}