Files
serein-flow/Library/FlowNode/Env/FlowCallTree.cs
fengjiayi 0d89ac1415 1. 脚本转c#代码功能,支持了[Flipflop]触发器节点
2. 修复了Script.StringNode转C#中存在多余的转义符的问题
3. 为IFlowControl添加了Task StratNodeAsync(string)的接口,用于在代码生成场景中的流程控制
4. 调整了关于Lightweight运行环境的文件位置
2025-08-04 22:38:20 +08:00

77 lines
2.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Serein.Library.Api;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Serein.Library
{
/// <summary>
/// 流程调用树,管理所有的调用节点
/// </summary>
public class FlowCallTree : IFlowCallTree
{
private readonly SortedDictionary<string, CallNode> _callNodes = new SortedDictionary<string,CallNode>();
/// <inheritdoc/>
public List<CallNode> StartNodes { get; set; }
/// <inheritdoc/>
public List<CallNode> GlobalFlipflopNodes { get; set; }
/// <summary>
/// 索引器允许通过字符串索引访问CallNode
/// </summary>
/// <param name="index"></param>
/// <returns></returns>
public CallNode this[string index]
{
get
{
_callNodes.TryGetValue(index, out CallNode callNode);
return callNode;
}
set
{
// 设置指定索引的值
_callNodes.Add(index, value);
}
}
/// <summary>
/// 添加一个调用节点到流程调用树中
/// </summary>
/// <param name="nodeGuid"></param>
/// <param name="action"></param>
public void AddCallNode(string nodeGuid, Action<IFlowContext> action)
{
var node = new CallNode(nodeGuid, action);
_callNodes[nodeGuid] = node;
}
/// <summary>
/// 添加一个调用节点到流程调用树中,使用异步函数
/// </summary>
/// <param name="nodeGuid"></param>
/// <param name="func"></param>
public void AddCallNode(string nodeGuid, Func<IFlowContext, Task> func)
{
var node = new CallNode(nodeGuid, func);
_callNodes[nodeGuid] = node;
}
/// <summary>
/// 获取指定Key的CallNode如果不存在则返回null
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public CallNode Get(string key)
{
return _callNodes.TryGetValue(key, out CallNode callNode) ? callNode : null;
}
}
}