using GFramework.Core.events;
namespace GFramework.Core.property;
///
/// 可绑定属性注销器类,用于取消注册可绑定属性的值变化监听
///
/// 可绑定属性的值类型
/// 需要注销的可绑定属性实例
/// 需要注销的值变化回调函数
public class BindablePropertyUnRegister(BindableProperty bindableProperty, Action onValueChanged)
: IUnRegister
{
///
/// 获取或设置可绑定属性实例
///
public BindableProperty BindableProperty { get; set; } = bindableProperty;
///
/// 获取或设置值变化时的回调函数
///
public Action OnValueChanged { get; set; } = onValueChanged;
///
/// 执行注销操作,取消注册值变化监听并清理引用
///
public void UnRegister()
{
// 调用可绑定属性的注销方法,传入值变化回调函数
BindableProperty.UnRegister(OnValueChanged);
// 清理属性引用
BindableProperty = null;
// 清理回调函数引用
OnValueChanged = null;
}
}