Files
serein-flow/NodeFlow/Model/Node/SingleUINode.cs

47 lines
1.4 KiB
C#
Raw Normal View History

2025-03-14 16:04:06 +08:00
using Serein.Library;
using Serein.Library.Api;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
2025-07-04 11:35:34 +08:00
namespace Serein.NodeFlow.Model
2025-03-14 16:04:06 +08:00
{
public class SingleUINode : NodeModelBase
{
public IEmbeddedContent Adapter { get; private set; }
public SingleUINode(IFlowEnvironment environment) : base(environment)
{
}
public override async Task<FlowResult> ExecutingAsync(IFlowContext context, CancellationToken token)
2025-03-14 16:04:06 +08:00
{
if (token.IsCancellationRequested) return new FlowResult(this.Guid, context);
2025-03-14 16:04:06 +08:00
if(Adapter is null)
{
var result = await base.ExecutingAsync(context, token);
if (result.Value is IEmbeddedContent adapter)
2025-03-14 16:04:06 +08:00
{
Adapter = adapter;
2025-03-14 16:04:06 +08:00
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);
2025-03-14 16:04:06 +08:00
}
return new FlowResult(this.Guid, context);
2025-03-14 16:04:06 +08:00
}
}
}