mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-03 00:00:49 +08:00
重写了节点主动中断功能,修改了运行环境持久化注册已有实例的逻辑。
This commit is contained in:
@@ -26,6 +26,7 @@ namespace Serein.Script
|
||||
/// </summary>
|
||||
public interface IScriptInvokeContext
|
||||
{
|
||||
IDynamicContext FlowContext { get; }
|
||||
/// <summary>
|
||||
/// 是否该退出了
|
||||
/// </summary>
|
||||
@@ -61,6 +62,13 @@ namespace Serein.Script
|
||||
|
||||
public class ScriptInvokeContext : IScriptInvokeContext
|
||||
{
|
||||
public ScriptInvokeContext(IDynamicContext dynamicContext)
|
||||
{
|
||||
FlowContext = dynamicContext;
|
||||
}
|
||||
|
||||
public IDynamicContext FlowContext{ get; }
|
||||
|
||||
/// <summary>
|
||||
/// 定义的变量
|
||||
/// </summary>
|
||||
@@ -76,6 +84,7 @@ namespace Serein.Script
|
||||
/// </summary>
|
||||
public bool IsCheckNullValue { get; set; }
|
||||
|
||||
|
||||
object IScriptInvokeContext.GetVarValue(string varName)
|
||||
{
|
||||
_variables.TryGetValue(varName, out var value);
|
||||
@@ -309,6 +318,11 @@ namespace Serein.Script
|
||||
}
|
||||
private async Task<object> InterpretFunctionCallAsync(IScriptInvokeContext context, FunctionCallNode functionCallNode)
|
||||
{
|
||||
if (functionCallNode.FunctionName.Equals("GetFlowContext", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return context.FlowContext;
|
||||
}
|
||||
|
||||
// 评估函数参数
|
||||
var arguments = new object?[functionCallNode.Arguments.Count];
|
||||
for (int i = 0; i < functionCallNode.Arguments.Count; i++)
|
||||
@@ -321,6 +335,7 @@ namespace Serein.Script
|
||||
|
||||
object? instance = null; // 静态方法不需要传入实例,所以可以传入null
|
||||
|
||||
|
||||
// 查找并执行对应的函数
|
||||
if (_functionTable.TryGetValue(funcName, out DelegateDetails? function))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user