优化了中断功能,增加了节点变量的查看。

This commit is contained in:
fengjiayi
2024-09-22 14:10:13 +08:00
parent 3537a49784
commit c930c870a6
26 changed files with 1686 additions and 494 deletions

View File

@@ -22,12 +22,11 @@ namespace Serein.NodeFlow.Model
public override async Task<object?> ExecutingAsync(IDynamicContext context)
{
#region
if (DebugSetting.IsInterrupt && TryCreateInterruptTask(context, this, out Task<CancelType>? task)) // 执行触发前
if (DebugSetting.InterruptClass != InterruptClass.None && TryCreateInterruptTask(context, this, out Task<CancelType>? task)) // 执行触发前
{
string guid = this.Guid.ToString();
this.CancelInterruptCallback ??= () => context.FlowEnvironment.ChannelFlowInterrupt.TriggerSignal(guid);
var cancelType = await task!;
task?.ToString();
await Console.Out.WriteLineAsync($"[{this.MethodDetails.MethodName}]中断已{(cancelType == CancelType.Manual ? "" : "")},开始执行后继分支");
}
#endregion
@@ -42,24 +41,9 @@ namespace Serein.NodeFlow.Model
Task<IFlipflopContext> flipflopTask = md.ExplicitDatas.Length switch
{
0 => ((Func<object, Task<IFlipflopContext>>)del).Invoke(md.ActingInstance),
_ => ((Func<object, object?[]?, Task<IFlipflopContext>>)del).Invoke(md.ActingInstance, GetParameters(context, md)), // 执行流程中的触发器方法时获取入参参数
_ => ((Func<object, object?[]?, Task<IFlipflopContext>>)del).Invoke(md.ActingInstance, GetParameters(context, this, md)), // 执行流程中的触发器方法时获取入参参数
};
//object?[]? parameters;
//object? result = null;
//if (haveParameter)
//{
// var data = GetParameters(context, md);
// parameters = [instance, data];
//}
//else
//{
// parameters = [instance];
//}
//flipflopTask = del.DynamicInvoke(parameters) as Task<IFlipflopContext>;
//if (flipflopTask == null)
//{
// throw new FlipflopException(base.MethodDetails.MethodName + "触发器返回值非 Task<IFlipflopContext> 类型");
//}
IFlipflopContext flipflopContext = (await flipflopTask) ?? throw new FlipflopException("没有返回上下文");
NextOrientation = flipflopContext.State.ToContentType();
if(flipflopContext.TriggerData is null || flipflopContext.TriggerData.Type == Library.NodeFlow.Tool.TriggerType.Overtime)
@@ -72,7 +56,7 @@ namespace Serein.NodeFlow.Model
{
NextOrientation = ConnectionType.None;
RuningException = ex;
throw;
return null;
}
catch (Exception ex)
{