开始编写BasalAction的基本属性与方法实现
This commit is contained in:
@@ -11,14 +11,91 @@ namespace Deedy.Activity
|
|||||||
{
|
{
|
||||||
public abstract class BasalAction : IActionElement
|
public abstract class BasalAction : IActionElement
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 扩展属性映射
|
||||||
|
/// </summary>
|
||||||
public ExpandoMapping ExpandoMapping { get; set; } = new ExpandoMapping();
|
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<T>(ref T field, [CallerMemberName, AllowNull] string propertyName = null)
|
||||||
|
{
|
||||||
|
T result = field;
|
||||||
|
switch (propertyName)
|
||||||
|
{
|
||||||
|
//返回前的自定义逻辑
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
protected virtual bool SetField<T>(ref T field, T value, [CallerMemberName, AllowNull] string propertyName = null)
|
||||||
|
{
|
||||||
|
if (EqualityComparer<T>.Default.Equals(field, value)) return false;
|
||||||
|
T _Value = value;
|
||||||
|
switch (propertyName)
|
||||||
|
{
|
||||||
|
//赋值前的自定义逻辑
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
field = _Value;
|
||||||
|
OnPropertyChanged(propertyName);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
protected internal BasalAction() { }
|
protected internal BasalAction() { }
|
||||||
public string Class { get; protected internal set; } = "";
|
public string Class { get; protected internal set; } = "";
|
||||||
public string Title { get; set; } = "";
|
protected internal string _Title = "";
|
||||||
public string Remark { get; set; } = "";
|
/// <summary>
|
||||||
public string Identify { get; set; } = "";
|
/// 标题名称
|
||||||
|
/// </summary>
|
||||||
|
public string Title
|
||||||
|
{
|
||||||
|
get { return GetField<string>(ref _Title); }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (SetField<string>(ref _Title, value))
|
||||||
|
{
|
||||||
|
// 这里可以加入属性变更后的处理逻辑
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected internal string _Remark = "";
|
||||||
|
/// <summary>
|
||||||
|
/// 描述信息
|
||||||
|
/// </summary>
|
||||||
|
public string Remark
|
||||||
|
{
|
||||||
|
get { return GetField<string>(ref _Remark); }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (SetField<string>(ref _Remark, value))
|
||||||
|
{
|
||||||
|
// 这里可以加入属性变更后的处理逻辑
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected internal string _Identify = "";
|
||||||
|
/// <summary>
|
||||||
|
/// 标识名称
|
||||||
|
/// </summary>
|
||||||
|
public string Identify
|
||||||
|
{
|
||||||
|
get { return GetField<string>(ref _Identify); }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (SetField<string>(ref _Identify, value))
|
||||||
|
{
|
||||||
|
// 这里可以加入属性变更后的处理逻辑
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
public int DepthLevel { get; protected internal set; } = 0;
|
public int DepthLevel { get; protected internal set; } = 0;
|
||||||
|
/// <summary>
|
||||||
|
/// 是否锁定
|
||||||
|
/// </summary>
|
||||||
public bool IsLocked { get; set; } = false;
|
public bool IsLocked { get; set; } = false;
|
||||||
protected internal LogInfo _InstantInfo = LogInfo.Empty;
|
protected internal LogInfo _InstantInfo = LogInfo.Empty;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -35,49 +112,24 @@ namespace Deedy.Activity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 父级节点
|
||||||
|
/// </summary>
|
||||||
public IElement? ParentElement { get; protected internal set; }
|
public IElement? ParentElement { get; protected internal set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 呈现视图
|
||||||
|
/// </summary>
|
||||||
public IActionViewer? ActionViewer { get; protected internal set; }
|
public IActionViewer? ActionViewer { get; protected internal set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 根级节点
|
||||||
|
/// </summary>
|
||||||
public IElement RootElement => (this.ParentElement == null) ? this : this.ParentElement.RootElement;
|
public IElement RootElement => (this.ParentElement == null) ? this : this.ParentElement.RootElement;
|
||||||
public Runtime? Runtime { get; protected internal set; }
|
public Runtime? Runtime { get; protected internal set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 参数映射
|
||||||
|
/// </summary>
|
||||||
public ParamDefineCollection ParamsMapping { get; set; } = [];
|
public ParamDefineCollection ParamsMapping { get; set; } = [];
|
||||||
|
|
||||||
public event PropertyChangedEventHandler? PropertyChanged;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 发送属性变更通知
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="propertyName">发生变更的属性</param>
|
|
||||||
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
||||||
/// <summary>
|
|
||||||
/// 读取一个字段的值
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">值的类型,可以通过参数进行自动判定</typeparam>
|
|
||||||
/// <param name="field">字段的引用【注意:此参数通过引用传递】</param>
|
|
||||||
/// <param name="propertyName">属性名称;如果在属性的读取访问器中调用可以自动注入</param>
|
|
||||||
/// <returns>字段中的值</returns>
|
|
||||||
protected virtual T GetField<T>(ref T field, [CallerMemberName] string? propertyName = null)
|
|
||||||
{
|
|
||||||
//TODO:这里处理内部属性获取逻辑(包括运行时参数映射逻辑)
|
|
||||||
return field;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 检查新值是否与原值相等,如果不相等便赋值并发出通知
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T">值的类型,可以通过参数进行自动判定</typeparam>
|
|
||||||
/// <param name="field">字段的引用【注意:此参数通过引用传递】</param>
|
|
||||||
/// <param name="value">字段的新值</param>
|
|
||||||
/// <param name="propertyName">要进行变更通知的属性名称;如果在属性的设置访问器中调用可以自动注入</param>
|
|
||||||
/// <returns>值是否有变更</returns>
|
|
||||||
protected virtual bool SetField<T>(ref T field, T value, [CallerMemberName] string? propertyName = null)
|
|
||||||
{
|
|
||||||
if (EqualityComparer<T>.Default.Equals(field, value)) return false;
|
|
||||||
//TODO:这里处理内部属性变更逻辑(包括运行时参数映射逻辑)
|
|
||||||
field = value;
|
|
||||||
OnPropertyChanged(propertyName);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LinkTo([AllowNull] IElement element)
|
public void LinkTo([AllowNull] IElement element)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
|||||||
Reference in New Issue
Block a user