重写了节点主动中断功能,修改了运行环境持久化注册已有实例的逻辑。

This commit is contained in:
fengjiayi
2024-12-26 22:24:44 +08:00
parent 7a6f8c407b
commit 3a7a8483e8
24 changed files with 428 additions and 563 deletions

View File

@@ -27,7 +27,7 @@ namespace Serein.NodeFlow.Model
if (DebugSetting.IsInterrupt) // 执行触发前
{
string guid = this.Guid.ToString();
await this.DebugSetting.GetInterruptTask();
await this.DebugSetting.GetInterruptTask.Invoke();
await Console.Out.WriteLineAsync($"[{this.MethodDetails.MethodName}]中断已取消,开始执行后继分支");
}
#endregion

View File

@@ -141,12 +141,23 @@ namespace Serein.NodeFlow.Model
public override async Task<object?> ExecutingAsync(IDynamicContext context)
{
var @params = await GetParametersAsync(context);
ScriptFlowApi.Context= context;
//dynamic obj = ((object[])@params[0])[0];
//try
//{
// SereinEnv.WriteLine(InfoType.INFO, "Dynamic Object Value " + obj.VarInfo);
//}
//catch (Exception ex)
//{
// SereinEnv.WriteLine(ex);
//}
//ScriptFlowApi.Context = context; // 并发破坏了数据状态
context.AddOrUpdate($"{context.Guid}_{this.Guid}_Params", @params[0]); // 后面再改
mainNode ??= new SereinScriptParser(Script).Parse();
IScriptInvokeContext scriptContext = new ScriptInvokeContext();
IScriptInvokeContext scriptContext = new ScriptInvokeContext(context);
var result = await ScriptInterpreter.InterpretAsync(scriptContext, mainNode); // 从入口节点执行
//SereinEnv.WriteLine(InfoType.INFO, "FlowContext Guid : " + context.Guid);
return result;
}