using Newtonsoft.Json.Linq; using Serein.Library.Api; using Serein.Library.Utils; using System; using System.Collections.Generic; using System.Diagnostics; using System.Text; using System.Threading.Tasks; namespace Serein.Library { /// /// 节点调试设置,用于中断节点的运行 /// [NodeProperty(ValuePath = NodeValuePath.DebugSetting)] public partial class NodeDebugSetting { /// /// 创建属于某个节点的调试设置 /// /// public NodeDebugSetting(IFlowNode nodeModel) { NodeModel = nodeModel; } /// /// 是否保护参数 /// [PropertyInfo(IsNotification = true)] private bool _isProtectionParameter = false; /// /// 对应的节点 /// [PropertyInfo(IsProtection = true)] private IFlowNode _nodeModel; /// /// 是否使能 /// [PropertyInfo(IsNotification = true)] private bool _isEnable = true; /// /// 是否中断节点。 /// [PropertyInfo(IsNotification = true)] private bool _isInterrupt = false; } /// /// 节点中断 /// public partial class NodeDebugSetting { /// /// 取消中断的回调函数 /// private Action _cancelInterrupt { get; set; } /// /// 取消中断 /// public Action CancelInterrupt => _cancelInterrupt; /// /// 中断节点 /// public Func _getInterruptTask; /// /// 获取中断的Task /// public Func GetInterruptTask => _getInterruptTask; partial void OnIsInterruptChanged(bool oldValue, bool newValue) { Debug.WriteLine($" {nameof(NodeDebugSetting)}.{nameof(NodeDebugSetting.OnIsInterruptChanged)} 暂未实现,需要重新设计中断逻辑"); /*if (newValue && _getInterruptTask is null) { // 设置获取中断的委托 _getInterruptTask = () => NodeModel.Env.IOC.Get().WaitTriggerAsync(NodeModel.Guid); } else if (!newValue) { if (_getInterruptTask is null) { } else { // 设置解除中断的委托 _cancelInterrupt = () => NodeModel.Env.IOC.Get().InvokeTrigger(NodeModel.Guid); _cancelInterrupt.Invoke(); _getInterruptTask = null; } }*/ } } }