using Serein.Library.Api;
using System;
using System.Diagnostics;
using System.Threading.Tasks;
namespace Serein.Library
{
///
/// 节点调试设置,用于中断节点的运行
///
[FlowDataProperty(ValuePath = NodeValuePath.DebugSetting)]
public partial class NodeDebugSetting
{
///
/// 创建属于某个节点的调试设置
///
///
public NodeDebugSetting(IFlowNode nodeModel)
{
NodeModel = nodeModel;
}
///
/// 是否保护参数
///
[DataInfo(IsNotification = true)]
private bool _isProtectionParameter = false;
///
/// 对应的节点
///
[DataInfo(IsProtection = true)]
private IFlowNode _nodeModel;
///
/// 是否使能
///
[DataInfo(IsNotification = true)]
private bool _isEnable = true;
///
/// 是否中断节点。
///
[DataInfo(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;
}
}*/
}
}
}