mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-20 08:16:34 +08:00
整理了Serein.Library项目类文件,IDynamicContext、DynamicContext接口名称及实现类改为IFlowContext、FlowContext,使其与流程其它接口类命名风格统一。
This commit is contained in:
@@ -10,21 +10,21 @@ namespace Serein.Library
|
||||
/// <summary>
|
||||
/// 动态流程上下文
|
||||
/// </summary>
|
||||
public class DynamicContext : IDynamicContext
|
||||
public class FlowContext : IFlowContext
|
||||
{
|
||||
/// <summary>
|
||||
/// 动态流程上下文
|
||||
/// </summary>
|
||||
/// <param name="flowEnvironment">脚本运行时的IOC</param>
|
||||
/// <param name="ioc">脚本运行时使用的IOC容器</param>
|
||||
public DynamicContext(IFlowEnvironment flowEnvironment)
|
||||
public FlowContext(IFlowEnvironment flowEnvironment)
|
||||
{
|
||||
Env = flowEnvironment;
|
||||
RunState = RunState.Running;
|
||||
}
|
||||
|
||||
private string _guid = global::System.Guid.NewGuid().ToString();
|
||||
string IDynamicContext.Guid => _guid;
|
||||
string IFlowContext.Guid => _guid;
|
||||
|
||||
/// <summary>
|
||||
/// 运行环境
|
||||
@@ -30,7 +30,7 @@ namespace Serein.Library
|
||||
/// </summary>
|
||||
/// <param name="nodeGuid"></param>
|
||||
/// <param name="context"></param>
|
||||
public FlowResult(string nodeGuid, IDynamicContext context, object value)
|
||||
public FlowResult(string nodeGuid, IFlowContext context, object value)
|
||||
{
|
||||
this.SourceNodeGuid = nodeGuid;
|
||||
this.ContextGuid = context.Guid;
|
||||
@@ -42,7 +42,7 @@ namespace Serein.Library
|
||||
/// </summary>
|
||||
/// <param name="nodeGuid"></param>
|
||||
/// <param name="context"></param>
|
||||
public FlowResult(string nodeGuid, IDynamicContext context)
|
||||
public FlowResult(string nodeGuid, IFlowContext context)
|
||||
{
|
||||
this.SourceNodeGuid = nodeGuid;
|
||||
this.ContextGuid = context.Guid;
|
||||
|
||||
@@ -98,12 +98,12 @@ namespace Serein.Library
|
||||
}
|
||||
}
|
||||
|
||||
public void AddCallNode(string nodeGuid, Action<IDynamicContext> action)
|
||||
public void AddCallNode(string nodeGuid, Action<IFlowContext> action)
|
||||
{
|
||||
var node = new CallNode(nodeGuid, action);
|
||||
_callNodes[nodeGuid] = node;
|
||||
}
|
||||
public void AddCallNode(string nodeGuid, Func<IDynamicContext, Task> func)
|
||||
public void AddCallNode(string nodeGuid, Func<IFlowContext, Task> func)
|
||||
{
|
||||
var node = new CallNode(nodeGuid, func);
|
||||
_callNodes[nodeGuid] = node;
|
||||
@@ -123,22 +123,22 @@ namespace Serein.Library
|
||||
public class CallNode
|
||||
{
|
||||
|
||||
private Func<IDynamicContext, Task> taskFunc;
|
||||
private Action<IDynamicContext> action;
|
||||
private Func<IFlowContext, Task> taskFunc;
|
||||
private Action<IFlowContext> action;
|
||||
|
||||
public CallNode(string nodeGuid)
|
||||
{
|
||||
Guid = nodeGuid;
|
||||
Init();
|
||||
}
|
||||
public CallNode(string nodeGuid, Action<IDynamicContext> action)
|
||||
public CallNode(string nodeGuid, Action<IFlowContext> action)
|
||||
{
|
||||
Guid = nodeGuid;
|
||||
this.action = action;
|
||||
Init();
|
||||
}
|
||||
|
||||
public CallNode(string nodeGuid, Func<IDynamicContext, Task> func)
|
||||
public CallNode(string nodeGuid, Func<IFlowContext, Task> func)
|
||||
{
|
||||
Guid = nodeGuid;
|
||||
this.taskFunc = func;
|
||||
@@ -158,11 +158,11 @@ namespace Serein.Library
|
||||
}
|
||||
|
||||
|
||||
public void SetAction(Action<IDynamicContext> action)
|
||||
public void SetAction(Action<IFlowContext> action)
|
||||
{
|
||||
this.action = action;
|
||||
}
|
||||
public void SetAction(Func<IDynamicContext, Task> taskFunc)
|
||||
public void SetAction(Func<IFlowContext, Task> taskFunc)
|
||||
{
|
||||
this.taskFunc = taskFunc;
|
||||
}
|
||||
@@ -245,7 +245,7 @@ namespace Serein.Library
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="InvalidOperationException"></exception>
|
||||
public async Task InvokeAsync(IDynamicContext context, CancellationToken token)
|
||||
public async Task InvokeAsync(IFlowContext context, CancellationToken token)
|
||||
{
|
||||
if (token.IsCancellationRequested)
|
||||
{
|
||||
@@ -274,7 +274,7 @@ namespace Serein.Library
|
||||
/// <param name="context"></param>
|
||||
/// <param name="token">流程运行</param>
|
||||
/// <returns></returns>
|
||||
public async Task<FlowResult> StartFlowAsync(IDynamicContext context, CancellationToken token)
|
||||
public async Task<FlowResult> StartFlowAsync(IFlowContext context, CancellationToken token)
|
||||
{
|
||||
var stack = _stackPool.Get();
|
||||
stack.Push(this);
|
||||
@@ -370,7 +370,7 @@ namespace Serein.Library
|
||||
{
|
||||
private readonly IFlowCallTree flowCallTree;
|
||||
private readonly IFlowEnvironment flowEnvironment;
|
||||
public static Serein.Library.Utils.ObjectPool<IDynamicContext> FlowContextPool { get; set; }
|
||||
public static Serein.Library.Utils.ObjectPool<IFlowContext> FlowContextPool { get; set; }
|
||||
|
||||
public ISereinIOC IOC => throw new NotImplementedException();
|
||||
|
||||
@@ -378,9 +378,9 @@ namespace Serein.Library
|
||||
{
|
||||
this.flowCallTree = flowCallTree;
|
||||
this.flowEnvironment = flowEnvironment;
|
||||
FlowContextPool = new Utils.ObjectPool<IDynamicContext>(() =>
|
||||
FlowContextPool = new Utils.ObjectPool<IFlowContext>(() =>
|
||||
{
|
||||
return new DynamicContext(flowEnvironment);
|
||||
return new FlowContext(flowEnvironment);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -400,7 +400,7 @@ namespace Serein.Library
|
||||
|
||||
public async Task<TResult> StartFlowAsync<TResult>(string startNodeGuid)
|
||||
{
|
||||
IDynamicContext context = Serein.Library.LightweightFlowControl.FlowContextPool.Allocate();
|
||||
IFlowContext context = Serein.Library.LightweightFlowControl.FlowContextPool.Allocate();
|
||||
CancellationTokenSource cts = new CancellationTokenSource();
|
||||
FlowResult flowResult;
|
||||
#if DEBUG
|
||||
|
||||
@@ -209,7 +209,7 @@ namespace Serein.Library
|
||||
return pd;
|
||||
}
|
||||
|
||||
public async Task<object> ToMethodArgData(IDynamicContext context)
|
||||
public async Task<object> ToMethodArgData(IFlowContext context)
|
||||
{
|
||||
// 1. 从缓存获取
|
||||
if (context.TryGetParamsTempData(NodeModel.Guid, Index, out var data))
|
||||
@@ -217,7 +217,7 @@ namespace Serein.Library
|
||||
|
||||
// 2. 特定快捷类型
|
||||
if (typeof(IFlowEnvironment).IsAssignableFrom(DataType)) return NodeModel.Env;
|
||||
if (typeof(IDynamicContext).IsAssignableFrom(DataType)) return context;
|
||||
if (typeof(IFlowContext).IsAssignableFrom(DataType)) return context;
|
||||
if (typeof(IFlowNode).IsAssignableFrom(DataType)) return NodeModel;
|
||||
|
||||
// 3. 显式常量参数
|
||||
@@ -296,7 +296,7 @@ namespace Serein.Library
|
||||
/// 转为方法入参数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<object> ToMethodArgData2(IDynamicContext context)
|
||||
public async Task<object> ToMethodArgData2(IFlowContext context)
|
||||
{
|
||||
|
||||
var nodeModel = NodeModel;
|
||||
@@ -316,7 +316,7 @@ namespace Serein.Library
|
||||
return env;
|
||||
}
|
||||
// 返回流程上下文
|
||||
if (typeof(IDynamicContext).IsAssignableFrom(DataType))
|
||||
if (typeof(IFlowContext).IsAssignableFrom(DataType))
|
||||
{
|
||||
return context;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user