mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-03 00:00:49 +08:00
完善节点图的代码生成
This commit is contained in:
@@ -29,6 +29,24 @@ namespace Serein.NodeFlow
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否为根节点
|
||||
/// </summary>
|
||||
/// <param name="node"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsRoot(this IFlowNode node)
|
||||
{
|
||||
var cts = NodeStaticConfig.ConnectionTypes;
|
||||
foreach (var ct in cts)
|
||||
{
|
||||
if (node.PreviousNodes[ct].Count > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 创建节点
|
||||
@@ -89,6 +107,8 @@ namespace Serein.NodeFlow
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 触发器运行后状态转为对应的后继分支类别
|
||||
/// </summary>
|
||||
@@ -107,6 +127,8 @@ namespace Serein.NodeFlow
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 判断 触发器节点 是否存在上游分支
|
||||
/// </summary>
|
||||
@@ -136,19 +158,27 @@ namespace Serein.NodeFlow
|
||||
/// <param name="retractCount">缩进次数(4个空格)</param>
|
||||
/// <param name="code">要添加的代码</param>
|
||||
/// <returns>字符串构建器本身</returns>
|
||||
public static StringBuilder AddCode(this StringBuilder sb,
|
||||
public static StringBuilder AppendCode(this StringBuilder sb,
|
||||
int retractCount = 0,
|
||||
string code = null)
|
||||
string code = null,
|
||||
bool isWrapping = true)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(code))
|
||||
{
|
||||
var retract = new string(' ', retractCount * 4);
|
||||
sb.AppendLine(retract + code);
|
||||
string retract = new string(' ', retractCount * 4);
|
||||
sb.Append(retract);
|
||||
if (isWrapping)
|
||||
{
|
||||
sb.AppendLine(code);
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append(code);
|
||||
}
|
||||
}
|
||||
return sb;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user