流程返回值改为FlowResult,记录节点信息、上下文信息,为以后的流程调用回溯做准备

This commit is contained in:
fengjiayi
2025-03-21 18:26:01 +08:00
parent 9941f24c5d
commit f99aff3c2c
30 changed files with 916 additions and 752 deletions

View File

@@ -22,7 +22,7 @@ namespace Serein.NodeFlow.Model
/// <param name="context"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public override async Task<object?> ExecutingAsync(IDynamicContext context, CancellationToken token)
public override async Task<FlowResult> ExecutingAsync(IDynamicContext context, CancellationToken token)
{
#region
if (DebugSetting.IsInterrupt) // 执行触发前
@@ -40,8 +40,13 @@ namespace Serein.NodeFlow.Model
}
var instance = context.Env.IOC.Get(md.ActingInstanceType);
if (instance is null)
{
Env.IOC.Register(md.ActingInstanceType).Build();
instance = Env.IOC.Get(md.ActingInstanceType);
}
await dd.InvokeAsync(instance, [context]);
var args = await GetParametersAsync(context, token);
var args = await this.GetParametersAsync(context, token);
// 因为这里会返回不确定的泛型 IFlipflopContext<TRsult>
// 而我们只需要获取到 State 和 Value返回的数据
// 所以使用 dynamic 类型接收
@@ -58,7 +63,9 @@ namespace Serein.NodeFlow.Model
{
throw new FlipflopException(base.MethodDetails.MethodName + "触发器超时触发。Guid" + base.Guid);
}
return dynamicFlipflopContext.Value;
object result = dynamicFlipflopContext.Value;
var flowReslt = new FlowResult(this, context, result);
return flowReslt;
}
}