mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-04-06 08:06:33 +08:00
重写脚本解释器的实现,提高其可读性。
This commit is contained in:
@@ -48,11 +48,7 @@ namespace Serein.NodeFlow.Env
|
||||
/// </summary>
|
||||
private RunState FlipFlopState = RunState.NoStart;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 异步运行
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <inheritdoc/>
|
||||
public async Task<bool> StartFlowAsync(string[] canvasGuids)
|
||||
{
|
||||
#region 校验参数
|
||||
@@ -144,12 +140,7 @@ namespace Serein.NodeFlow.Env
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 从选定节点开始运行
|
||||
/// </summary>
|
||||
/// <param name="startNodeGuid"></param>
|
||||
/// <returns></returns>
|
||||
/// <inheritdoc/>
|
||||
public async Task<TResult> StartFlowAsync<TResult>(string startNodeGuid)
|
||||
{
|
||||
|
||||
@@ -207,10 +198,7 @@ namespace Serein.NodeFlow.Env
|
||||
}
|
||||
return result;
|
||||
}*/
|
||||
|
||||
/// <summary>
|
||||
/// 结束流程
|
||||
/// </summary>
|
||||
/// <inheritdoc/>
|
||||
public Task<bool> ExitFlowAsync()
|
||||
{
|
||||
flowWorkManagement?.Exit();
|
||||
@@ -220,11 +208,7 @@ namespace Serein.NodeFlow.Env
|
||||
GC.Collect();
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 激活全局触发器
|
||||
/// </summary>
|
||||
/// <param name="nodeGuid"></param>
|
||||
/// <inheritdoc/>
|
||||
public void ActivateFlipflopNode(string nodeGuid)
|
||||
{
|
||||
/*if (!TryGetNodeModel(nodeGuid, out var nodeModel))
|
||||
@@ -242,11 +226,7 @@ namespace Serein.NodeFlow.Env
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭全局触发器
|
||||
/// </summary>
|
||||
/// <param name="nodeGuid"></param>
|
||||
/// <inheritdoc/>
|
||||
public void TerminateFlipflopNode(string nodeGuid)
|
||||
{
|
||||
/* if (!TryGetNodeModel(nodeGuid, out var nodeModel))
|
||||
@@ -264,24 +244,12 @@ namespace Serein.NodeFlow.Env
|
||||
{
|
||||
this.sereinIOC = ioc; // 设置IOC容器
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 启动器调用,运行到某个节点时触发了监视对象的更新(对象预览视图将会自动更新)
|
||||
/// </summary>
|
||||
/// <param name="nodeGuid"></param>
|
||||
/// <param name="monitorData"></param>
|
||||
/// <param name="sourceType"></param>
|
||||
/// <inheritdoc/>
|
||||
public void MonitorObjectNotification(string nodeGuid, object monitorData, MonitorObjectEventArgs.ObjSourceType sourceType)
|
||||
{
|
||||
flowEnvironmentEvent.OnMonitorObjectChanged(new MonitorObjectEventArgs(nodeGuid, monitorData, sourceType));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 启动器调用,节点触发了中断。
|
||||
/// </summary>
|
||||
/// <param name="nodeGuid">节点</param>
|
||||
/// <param name="expression">表达式</param>
|
||||
/// <param name="type">类型,0用户主动的中断,1表达式中断</param>
|
||||
/// <inheritdoc/>
|
||||
public void TriggerInterrupt(string nodeGuid, string expression, InterruptTriggerEventArgs.InterruptTriggerType type)
|
||||
{
|
||||
flowEnvironmentEvent.OnInterruptTriggered(new InterruptTriggerEventArgs(nodeGuid, expression, type));
|
||||
@@ -292,28 +260,14 @@ namespace Serein.NodeFlow.Env
|
||||
|
||||
#region 流程接口调用
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 调用流程接口,将返回 FlowResult.Value。如果需要 FlowResult 对象,请使用该方法的泛型版本。
|
||||
/// </summary>
|
||||
/// <param name="apiGuid">流程接口节点Guid</param>
|
||||
/// <param name="dict">调用时入参参数</param>
|
||||
/// <returns></returns>
|
||||
/// <inheritdoc/>
|
||||
public async Task<object> InvokeAsync(string apiGuid, Dictionary<string, object> dict)
|
||||
{
|
||||
var result = await InvokeAsync<object>(apiGuid, dict);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 调用流程接口,泛型类型为 FlowResult 时,将返回 FlowResult 对象。
|
||||
/// </summary>
|
||||
/// <typeparam name="TResult"></typeparam>
|
||||
/// <param name="apiGuid">流程接口节点Guid</param>
|
||||
/// <param name="dict">调用时入参参数</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
/// <inheritdoc/>
|
||||
public async Task<TResult> InvokeAsync<TResult>(string apiGuid, Dictionary<string, object> dict)
|
||||
{
|
||||
if (sereinIOC is null)
|
||||
|
||||
@@ -201,7 +201,7 @@ namespace Serein.NodeFlow.Env
|
||||
private int _add_canvas_count = 1;
|
||||
|
||||
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void CreateCanvas(string canvasName, int width, int height)
|
||||
{
|
||||
IOperation operation = new CreateCanvasOperation
|
||||
@@ -219,7 +219,7 @@ namespace Serein.NodeFlow.Env
|
||||
|
||||
flowOperationService.Execute(operation);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void RemoveCanvas(string canvasGuid)
|
||||
{
|
||||
IOperation operation = new RemoveCanvasOperation
|
||||
@@ -228,7 +228,7 @@ namespace Serein.NodeFlow.Env
|
||||
};
|
||||
flowOperationService.Execute(operation);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void ConnectInvokeNode(string canvasGuid, string fromNodeGuid, string toNodeGuid, JunctionType fromNodeJunctionType, JunctionType toNodeJunctionType, ConnectionInvokeType invokeType)
|
||||
{
|
||||
IOperation operation = new ChangeNodeConnectionOperation
|
||||
@@ -245,7 +245,7 @@ namespace Serein.NodeFlow.Env
|
||||
|
||||
flowOperationService.Execute(operation);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void ConnectArgSourceNode(string canvasGuid, string fromNodeGuid, string toNodeGuid, JunctionType fromNodeJunctionType, JunctionType toNodeJunctionType, ConnectionArgSourceType argSourceType, int argIndex)
|
||||
{
|
||||
IOperation operation = new ChangeNodeConnectionOperation
|
||||
@@ -262,7 +262,7 @@ namespace Serein.NodeFlow.Env
|
||||
};
|
||||
flowOperationService.Execute(operation);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void RemoveInvokeConnect(string canvasGuid, string fromNodeGuid, string toNodeGuid, ConnectionInvokeType connectionType)
|
||||
{
|
||||
IOperation operation = new ChangeNodeConnectionOperation
|
||||
@@ -276,7 +276,7 @@ namespace Serein.NodeFlow.Env
|
||||
};
|
||||
flowOperationService.Execute(operation);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void RemoveArgSourceConnect(string canvasGuid, string fromNodeGuid, string toNodeGuid, int argIndex)
|
||||
{
|
||||
IOperation operation = new ChangeNodeConnectionOperation
|
||||
@@ -290,7 +290,7 @@ namespace Serein.NodeFlow.Env
|
||||
};
|
||||
flowOperationService.Execute(operation);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void CreateNode(string canvasGuid, NodeControlType nodeType, PositionOfUI position, MethodDetailsInfo methodDetailsInfo = null)
|
||||
{
|
||||
IOperation operation = new CreateNodeOperation
|
||||
@@ -302,7 +302,7 @@ namespace Serein.NodeFlow.Env
|
||||
};
|
||||
flowOperationService.Execute(operation);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void RemoveNode(string canvasGuid, string nodeGuid)
|
||||
{
|
||||
IOperation operation = new RemoveNodeOperation
|
||||
@@ -312,7 +312,7 @@ namespace Serein.NodeFlow.Env
|
||||
};
|
||||
flowOperationService.Execute(operation);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void PlaceNodeToContainer(string canvasGuid, string nodeGuid, string containerNodeGuid)
|
||||
{
|
||||
IOperation operation = new ContainerPlaceNodeOperation
|
||||
@@ -323,7 +323,7 @@ namespace Serein.NodeFlow.Env
|
||||
};
|
||||
flowOperationService.Execute(operation);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void TakeOutNodeToContainer(string canvasGuid, string nodeGuid)
|
||||
{
|
||||
IOperation operation = new ContainerTakeOutNodeOperation
|
||||
@@ -333,7 +333,7 @@ namespace Serein.NodeFlow.Env
|
||||
};
|
||||
flowOperationService.Execute(operation);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void SetStartNode(string canvasGuid, string nodeGuid)
|
||||
{
|
||||
|
||||
@@ -363,7 +363,7 @@ namespace Serein.NodeFlow.Env
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void SetConnectPriorityInvoke(string fromNodeGuid, string toNodeGuid, ConnectionInvokeType connectionType)
|
||||
{
|
||||
|
||||
@@ -377,7 +377,7 @@ namespace Serein.NodeFlow.Env
|
||||
};
|
||||
flowOperationService.Execute(operation);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void ChangeParameter(string nodeGuid, bool isAdd, int paramIndex)
|
||||
{
|
||||
IOperation operation = new ChangeParameterOperation
|
||||
@@ -389,12 +389,7 @@ namespace Serein.NodeFlow.Env
|
||||
flowOperationService.Execute(operation);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从节点信息集合批量加载节点控件
|
||||
/// </summary>
|
||||
/// <param name="List<NodeInfo>">节点信息</param>
|
||||
/// <returns></returns>
|
||||
///
|
||||
/// <inheritdoc/>
|
||||
public async Task LoadNodeInfosAsync(List<NodeInfo> nodeInfos)
|
||||
{
|
||||
#region 从NodeInfo创建NodeModel
|
||||
@@ -635,11 +630,7 @@ namespace Serein.NodeFlow.Env
|
||||
|
||||
|
||||
#region 视觉效果
|
||||
|
||||
/// <summary>
|
||||
/// 定位节点
|
||||
/// </summary>
|
||||
/// <param name="nodeGuid"></param>
|
||||
/// <inheritdoc/>
|
||||
public void NodeLocate(string nodeGuid)
|
||||
{
|
||||
if (OperatingSystem.IsWindows())
|
||||
|
||||
Reference in New Issue
Block a user