mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 19:03:29 +08:00
- 将架构相关接口从 GFramework.Core 迁移至 GFramework.Core.Abstractions 项目 - 更新项目引用配置,添加对抽象层项目的项目引用 - 修正命名空间引用,使用新的抽象层命名空间 - 调整类型定义,将 List<T> 替换为更通用的 IList<T> 接口 - 修复控制器接口命名空间错误 - 添加必要的 using 语句以支持新的抽象层引用
36 lines
1.3 KiB
C#
36 lines
1.3 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()
|
|
{
|
|
// 调用可绑定属性的注销方法,传入值变化回调函数
|
|
BindableProperty.UnRegister(OnValueChanged);
|
|
// 清理属性引用
|
|
BindableProperty = null;
|
|
// 清理回调函数引用
|
|
OnValueChanged = null;
|
|
}
|
|
} |