mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-20 00:06:45 +08:00
1. 重新设计了Generate项目及相关特性的命名,避免与其他类型混淆。
2. 补充了部分注释。 3. 修改了删除容器节点时,容器内子节点未正确删除的问题。
This commit is contained in:
63
NodeFlow/Model/Nodes/SingleUINode.cs
Normal file
63
NodeFlow/Model/Nodes/SingleUINode.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using Serein.Library;
|
||||
using Serein.Library.Api;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serein.NodeFlow.Model.Nodes
|
||||
{
|
||||
/// <summary>
|
||||
/// 单个UI节点,适用于需要在流程中嵌入用户自定义控件的场景。
|
||||
/// </summary>
|
||||
public class SingleUINode : NodeModelBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 适配的UI控件,必须实现IEmbeddedContent接口。
|
||||
/// </summary>
|
||||
public IEmbeddedContent? Adapter { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单个UI节点构造函数,初始化流程环境。
|
||||
/// </summary>
|
||||
/// <param name="environment"></param>
|
||||
public SingleUINode(IFlowEnvironment environment) : base(environment)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行节点逻辑,适用于嵌入式UI控件的流程节点。
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
public override async Task<FlowResult> ExecutingAsync(IFlowContext context, CancellationToken token)
|
||||
{
|
||||
if (token.IsCancellationRequested) return FlowResult.Fail(this.Guid, context, "流程已通过token取消");
|
||||
if(Adapter is null)
|
||||
{
|
||||
|
||||
var result = await base.ExecutingAsync(context, token);
|
||||
if (result.Value is IEmbeddedContent adapter)
|
||||
{
|
||||
Adapter = adapter;
|
||||
context.NextOrientation = ConnectionInvokeType.IsSucceed;
|
||||
}
|
||||
else
|
||||
{
|
||||
context.NextOrientation = ConnectionInvokeType.IsError;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var p = context.GetPreviousNode(this.Guid);
|
||||
var data = context.GetFlowData(p).Value;
|
||||
var iflowContorl = Adapter.GetFlowControl();
|
||||
iflowContorl.OnExecuting(data);
|
||||
}
|
||||
|
||||
return FlowResult.OK(this.Guid, context, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user