Files
DeedyDesigner/DeedyDesigner/Deedy.Activity/BasalAction.cs
2025-09-19 20:25:20 +08:00

116 lines
4.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace Deedy.Activity
{
public abstract class BasalAction : IActionElement
{
public ExpandoMapping ExpandoMapping { get; set; } = new ExpandoMapping();
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; } = "";
public int DepthLevel { get; protected internal set; } = 0;
public bool IsLocked { get; set; } = false;
protected internal LogInfo _InstantInfo = LogInfo.Empty;
/// <summary>
/// 即时消息
/// </summary>
public LogInfo InstantInfo
{
get { return GetField<LogInfo>(ref _InstantInfo); }
set
{
if (SetField<LogInfo>(ref _InstantInfo, value))
{
// 这里可以加入属性变更后的处理逻辑
}
}
}
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 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 ReadyToWorking(IElement? element = null, Output? output = null)
{
throw new NotImplementedException();
}
public void ReadyToEditing(Runtime runtime)
{
throw new NotImplementedException();
}
public void ReadyToRunning(Runtime runtime)
{
throw new NotImplementedException();
}
public void LinkTo([AllowNull] IElement element)
{
throw new NotImplementedException();
}
public void Unlink()
{
throw new NotImplementedException();
}
public IElement? Clone()
{
throw new NotImplementedException();
}
public bool TryEncode(out string document)
{
throw new NotImplementedException();
}
}
}