mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 10:34:30 +08:00
- 新增 Architecture 基类与 IArchitecture 接口,实现单例模式与组件注册管理 - 集成 IOC 容器支持系统、模型、工具的依赖注入与生命周期管理 - 实现命令模式基础类 AbstractCommand 与接口 ICommand,支持带返回值命令 - 提供事件系统集成,支持事件的发布与订阅机制 - 添加控制器接口 IController,整合命令发送、事件注册与模型获取能力 - 创建详细的 README 文档说明各组件使用方式与设计模式应用 - 支持命令、查询、事件的统一调度与解耦通信机制
39 lines
1.3 KiB
C#
39 lines
1.3 KiB
C#
using System;
|
|
using GFramework.framework.events;
|
|
|
|
namespace GFramework.framework.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;
|
|
}
|
|
}
|