mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 19:03:29 +08:00
- 从 ArchitectureContext 构造函数中移除 LoggerProperties 参数 - 更新 Architecture 类中上下文初始化逻辑,不再传递日志属性 - 优化事件系统中的空值安全处理 - 修正 EasyEvent 泛型类中的类型参数命名 - 移除不再需要的 IsExternalInit 内部实现 - 更新包引用配置添加 PrivateAssets 属性
41 lines
1.4 KiB
C#
41 lines
1.4 KiB
C#
using GFramework.Core.Abstractions.events;
|
|
|
|
namespace GFramework.Core.property;
|
|
|
|
/// <summary>
|
|
/// 可绑定属性注销器类,用于取消注册可绑定属性的值变化监听
|
|
/// </summary>
|
|
/// <typeparam name="T">可绑定属性的值类型</typeparam>
|
|
/// <param name="bindableProperty">需要注销的可绑定属性实例</param>
|
|
/// <param name="onValueChanged">需要注销的值变化回调函数</param>
|
|
public class BindablePropertyUnRegister<T>(BindableProperty<T> bindableProperty, Action<T> onValueChanged)
|
|
: IUnRegister
|
|
{
|
|
/// <summary>
|
|
/// 获取或设置可绑定属性实例
|
|
/// </summary>
|
|
public BindableProperty<T>? BindableProperty { get; set; } = bindableProperty;
|
|
|
|
/// <summary>
|
|
/// 获取或设置值变化时的回调函数
|
|
/// </summary>
|
|
public Action<T>? OnValueChanged { get; set; } = onValueChanged;
|
|
|
|
/// <summary>
|
|
/// 执行注销操作,取消注册值变化监听并清理引用
|
|
/// </summary>
|
|
public void UnRegister()
|
|
{
|
|
// 检查两个引用都不为null时才执行注销操作
|
|
if (BindableProperty != null && OnValueChanged != null)
|
|
{
|
|
// 调用可绑定属性的注销方法,传入值变化回调函数
|
|
BindableProperty.UnRegister(OnValueChanged);
|
|
}
|
|
|
|
// 清理属性引用
|
|
BindableProperty = null;
|
|
// 清理回调函数引用
|
|
OnValueChanged = null;
|
|
}
|
|
} |