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)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-21 18:26:01 +08:00
|
|
|
|
public override async Task<FlowResult> ExecutingAsync(IDynamicContext context, CancellationToken token)
|
2025-03-14 16:04:06 +08:00
|
|
|
|
{
|
2025-03-21 18:26:01 +08:00
|
|
|
|
if (token.IsCancellationRequested) return new FlowResult(this,context);
|
2025-03-14 16:04:06 +08:00
|
|
|
|
if(Adapter is null)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
2025-03-20 22:54:10 +08:00
|
|
|
|
var result = await base.ExecutingAsync(context, token);
|
2025-03-21 18:26:01 +08:00
|
|
|
|
if (result.Value is IEmbeddedContent adapter)
|
2025-03-14 16:04:06 +08:00
|
|
|
|
{
|
2025-06-22 21:53:37 +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);
|
2025-03-21 18:26:01 +08:00
|
|
|
|
var data = context.GetFlowData(p).Value;
|
2025-03-17 11:57:06 +08:00
|
|
|
|
var iflowContorl = Adapter.GetFlowControl();
|
|
|
|
|
|
iflowContorl.OnExecuting(data);
|
2025-03-14 16:04:06 +08:00
|
|
|
|
}
|
2025-03-21 18:26:01 +08:00
|
|
|
|
|
|
|
|
|
|
return new FlowResult(this, context);
|
2025-03-14 16:04:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|