From b66885c2b601ea12e52a25f98015b920c6c3e8ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E6=99=BA=E7=BA=AF?= <于智纯@LODESTAR> Date: Sun, 21 Sep 2025 14:19:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=A7=8B=E7=BC=96=E5=86=99BasalAction?= =?UTF-8?q?=E7=9A=84=E5=9F=BA=E6=9C=AC=E5=B1=9E=E6=80=A7=E4=B8=8E=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DeedyDesigner/Deedy.Activity/BasalAction.cs | 136 ++++++++++++++------ 1 file changed, 94 insertions(+), 42 deletions(-) diff --git a/DeedyDesigner/Deedy.Activity/BasalAction.cs b/DeedyDesigner/Deedy.Activity/BasalAction.cs index 0b010c7..5216c85 100644 --- a/DeedyDesigner/Deedy.Activity/BasalAction.cs +++ b/DeedyDesigner/Deedy.Activity/BasalAction.cs @@ -11,14 +11,91 @@ namespace Deedy.Activity { public abstract class BasalAction : IActionElement { + /// + /// 扩展属性映射 + /// public ExpandoMapping ExpandoMapping { get; set; } = new ExpandoMapping(); - + #region 定义属性通知事件相关方法 + public event PropertyChangedEventHandler? PropertyChanged; + protected virtual void OnPropertyChanged([CallerMemberName, AllowNull] string propertyName = null) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + protected virtual T GetField(ref T field, [CallerMemberName, AllowNull] string propertyName = null) + { + T result = field; + switch (propertyName) + { + //返回前的自定义逻辑 + default: break; + } + return result; + } + protected virtual bool SetField(ref T field, T value, [CallerMemberName, AllowNull] string propertyName = null) + { + if (EqualityComparer.Default.Equals(field, value)) return false; + T _Value = value; + switch (propertyName) + { + //赋值前的自定义逻辑 + default: break; + } + field = _Value; + OnPropertyChanged(propertyName); + return true; + } + #endregion protected internal BasalAction() { } public string Class { get; protected internal set; } = ""; - public string Title { get; set; } = ""; - public string Remark { get; set; } = ""; - public string Identify { get; set; } = ""; + protected internal string _Title = ""; + /// + /// 标题名称 + /// + public string Title + { + get { return GetField(ref _Title); } + set + { + if (SetField(ref _Title, value)) + { + // 这里可以加入属性变更后的处理逻辑 + } + } + } + protected internal string _Remark = ""; + /// + /// 描述信息 + /// + public string Remark + { + get { return GetField(ref _Remark); } + set + { + if (SetField(ref _Remark, value)) + { + // 这里可以加入属性变更后的处理逻辑 + } + } + } + protected internal string _Identify = ""; + /// + /// 标识名称 + /// + public string Identify + { + get { return GetField(ref _Identify); } + set + { + if (SetField(ref _Identify, value)) + { + // 这里可以加入属性变更后的处理逻辑 + } + } + } public int DepthLevel { get; protected internal set; } = 0; + /// + /// 是否锁定 + /// public bool IsLocked { get; set; } = false; protected internal LogInfo _InstantInfo = LogInfo.Empty; /// @@ -35,49 +112,24 @@ namespace Deedy.Activity } } } + /// + /// 父级节点 + /// public IElement? ParentElement { get; protected internal set; } + /// + /// 呈现视图 + /// public IActionViewer? ActionViewer { get; protected internal set; } - + /// + /// 根级节点 + /// public IElement RootElement => (this.ParentElement == null) ? this : this.ParentElement.RootElement; - public Runtime? Runtime { get; protected internal set; } + public Runtime? Runtime { get; protected internal set; } + /// + /// 参数映射 + /// public ParamDefineCollection ParamsMapping { get; set; } = []; - public event PropertyChangedEventHandler? PropertyChanged; - - /// - /// 发送属性变更通知 - /// - /// 发生变更的属性 - protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); - /// - /// 读取一个字段的值 - /// - /// 值的类型,可以通过参数进行自动判定 - /// 字段的引用【注意:此参数通过引用传递】 - /// 属性名称;如果在属性的读取访问器中调用可以自动注入 - /// 字段中的值 - protected virtual T GetField(ref T field, [CallerMemberName] string? propertyName = null) - { - //TODO:这里处理内部属性获取逻辑(包括运行时参数映射逻辑) - return field; - } - /// - /// 检查新值是否与原值相等,如果不相等便赋值并发出通知 - /// - /// 值的类型,可以通过参数进行自动判定 - /// 字段的引用【注意:此参数通过引用传递】 - /// 字段的新值 - /// 要进行变更通知的属性名称;如果在属性的设置访问器中调用可以自动注入 - /// 值是否有变更 - protected virtual bool SetField(ref T field, T value, [CallerMemberName] string? propertyName = null) - { - if (EqualityComparer.Default.Equals(field, value)) return false; - //TODO:这里处理内部属性变更逻辑(包括运行时参数映射逻辑) - field = value; - OnPropertyChanged(propertyName); - return true; - } - public void LinkTo([AllowNull] IElement element) { throw new NotImplementedException();