mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-02 15:50:47 +08:00
重新设计接口类,将流程运行环境和IOC解耦
This commit is contained in:
@@ -31,11 +31,11 @@ namespace Serein.FlowStartTool
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// env = new FlowEnvironmentDecorator(uIContextOperation);
|
||||
// env = new FlowEnvironment(uIContextOperation);
|
||||
// this.window = window;
|
||||
//}
|
||||
|
||||
Env = new FlowEnvironmentDecorator();
|
||||
Env = new FlowEnvironment();
|
||||
Env.SetUIContextOperation(uIContextOperation);
|
||||
Env.LoadProject(new FlowEnvInfo { Project = flowProjectData }, fileDataPath); // 加载项目
|
||||
|
||||
|
||||
@@ -739,6 +739,7 @@ namespace Serein.Library.Api
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 运行环境
|
||||
/// </summary>
|
||||
@@ -758,7 +759,6 @@ namespace Serein.Library.Api
|
||||
/// </summary>
|
||||
string EnvName { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 项目文件位置
|
||||
/// </summary>
|
||||
@@ -785,11 +785,6 @@ namespace Serein.Library.Api
|
||||
/// </summary>
|
||||
RunState FlowState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 全局触发器运行状态
|
||||
/// </summary>
|
||||
//RunState FlipFlopState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 表示当前环境
|
||||
/// </summary>
|
||||
@@ -811,8 +806,9 @@ namespace Serein.Library.Api
|
||||
/// <summary>
|
||||
/// 输出信息
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="message">消息</param>
|
||||
/// <param name="type">输出类型</param>
|
||||
/// <param name="class">输出级别</param>
|
||||
void WriteLine(InfoType type, string message, InfoClass @class = InfoClass.Trivial);
|
||||
|
||||
/// <summary>
|
||||
@@ -840,7 +836,6 @@ namespace Serein.Library.Api
|
||||
/// <returns></returns>
|
||||
Task LoadNodeInfosAsync(List<NodeInfo> nodeInfos);
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 远程相关
|
||||
@@ -906,6 +901,7 @@ namespace Serein.Library.Api
|
||||
/// <summary>
|
||||
/// 移动了某个节点(远程插件使用)
|
||||
/// </summary>
|
||||
/// <param name="canvasGuid">所在画布</param>
|
||||
/// <param name="nodeGuid"></param>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
@@ -914,6 +910,7 @@ namespace Serein.Library.Api
|
||||
/// <summary>
|
||||
/// 设置流程起点节点
|
||||
/// </summary>
|
||||
/// <param name="canvasGuid">所在画布</param>
|
||||
/// <param name="nodeGuid">尝试设置为起始节点的节点Guid</param>
|
||||
/// <returns>被设置为起始节点的Guid</returns>
|
||||
Task<string> SetStartNodeAsync(string canvasGuid, string nodeGuid);
|
||||
@@ -921,6 +918,7 @@ namespace Serein.Library.Api
|
||||
/// <summary>
|
||||
/// 在两个节点之间创建连接关系
|
||||
/// </summary>
|
||||
/// <param name="canvasGuid">所在画布</param>
|
||||
/// <param name="fromNodeGuid">起始节点Guid</param>
|
||||
/// <param name="toNodeGuid">目标节点Guid</param>
|
||||
/// <param name="fromNodeJunctionType">起始节点控制点</param>
|
||||
@@ -936,6 +934,7 @@ namespace Serein.Library.Api
|
||||
/// <summary>
|
||||
/// 在两个节点之间创建连接关系
|
||||
/// </summary>
|
||||
/// <param name="canvasGuid">所在画布</param>
|
||||
/// <param name="fromNodeGuid">起始节点Guid</param>
|
||||
/// <param name="toNodeGuid">目标节点Guid</param>
|
||||
/// <param name="fromNodeJunctionType">起始节点控制点</param>
|
||||
@@ -950,26 +949,32 @@ namespace Serein.Library.Api
|
||||
ConnectionArgSourceType argSourceType,
|
||||
int argIndex);
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 创建节点
|
||||
/// </summary>
|
||||
/// <param name="canvasGuid">所在画布</param>
|
||||
/// <param name="nodeType">控件类型</param>
|
||||
/// <param name="position">节点在画布上的位置(</param>
|
||||
/// <param name="methodDetailsInfo">节点绑定的方法说明</param>
|
||||
Task<NodeInfo> CreateNodeAsync(string canvasGuid, NodeControlType nodeType, PositionOfUI position, MethodDetailsInfo methodDetailsInfo = null);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 将节点放置在容器中
|
||||
/// 将节点放置在容器中
|
||||
/// </summary>
|
||||
/// <param name="canvasGuid">所在画布</param>
|
||||
/// <param name="nodeGuid">需要放置的节点Guid</param>
|
||||
/// <param name="containerNodeGuid">存放节点的容器Guid</param>
|
||||
/// <returns></returns>
|
||||
Task<bool> PlaceNodeToContainerAsync(string canvasGuid, string nodeGuid, string containerNodeGuid);
|
||||
|
||||
/// <summary>
|
||||
/// 将节点从容器中脱离
|
||||
/// 将节点放置在容器中
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <param name="canvasGuid">所在画布</param>
|
||||
/// <param name="nodeGuid">需要取出的节点Guid</param>
|
||||
Task<bool> TakeOutNodeToContainerAsync(string canvasGuid, string nodeGuid);
|
||||
|
||||
|
||||
@@ -984,7 +989,8 @@ namespace Serein.Library.Api
|
||||
|
||||
/// <summary>
|
||||
/// 移除两个节点之间的方法调用关系
|
||||
/// </summary>
|
||||
/// </summary>
|
||||
/// <param name="canvasGuid">所在画布</param>
|
||||
/// <param name="fromNodeGuid">起始节点</param>
|
||||
/// <param name="toNodeGuid">目标节点</param>
|
||||
/// <param name="connectionType">连接类型</param>
|
||||
@@ -993,15 +999,16 @@ namespace Serein.Library.Api
|
||||
/// <summary>
|
||||
/// 移除连接节点之间参数传递的关系
|
||||
/// </summary>
|
||||
/// <param name="canvasGuid">所在画布</param>
|
||||
/// <param name="fromNodeGuid">起始节点Guid</param>
|
||||
/// <param name="toNodeGuid">目标节点Guid</param>
|
||||
/// <param name="argIndex">连接到第几个参数</param>
|
||||
/// <param name="connectionArgSourceType">参数来源类型</param>
|
||||
Task<bool> RemoveConnectArgSourceAsync(string canvasGuid, string fromNodeGuid, string toNodeGuid, int argIndex);
|
||||
|
||||
/// <summary>
|
||||
/// 移除节点/区域/基础控件
|
||||
/// </summary>
|
||||
/// <param name="canvasGuid">所在画布</param>
|
||||
/// <param name="nodeGuid">待移除的节点Guid</param>
|
||||
Task<bool> RemoveNodeAsync(string canvasGuid, string nodeGuid);
|
||||
|
||||
@@ -1089,11 +1096,21 @@ namespace Serein.Library.Api
|
||||
bool TryGetDelegateDetails(string assemblyName, string methodName, out DelegateDetails del);
|
||||
|
||||
/// <summary>
|
||||
/// 提供设置UI上下文的能力
|
||||
/// <para>提供设置UI上下文的能力</para>
|
||||
/// <para>提供设置UI上下文的能力,在WinForm/WPF项目中,在UI线程外对UI元素的修改将会导致异常</para>
|
||||
/// <para>需要你提供</para>
|
||||
/// </summary>
|
||||
/// <param name="uiContextOperation"></param>
|
||||
void SetUIContextOperation(UIContextOperation uiContextOperation);
|
||||
|
||||
/// <summary>
|
||||
/// <para>需要你提供一个由你实现的ISereinIOC接口实现类</para>
|
||||
/// <para>当你将流程运行环境集成在你的项目时,并希望流程运行时使用你提供的对象,而非自动创建</para>
|
||||
/// <para>就需要你调用这个方法,用来替换运行环境的IOC容器</para>
|
||||
/// </summary>
|
||||
/// <param name="ioc"></param>
|
||||
void UseExternalIOC(ISereinIOC ioc);
|
||||
|
||||
/// <summary>
|
||||
/// 开始运行流程
|
||||
/// </summary>
|
||||
@@ -1101,7 +1118,6 @@ namespace Serein.Library.Api
|
||||
/// <returns></returns>
|
||||
Task<bool> StartFlowAsync(string[] canvasGuids);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 从选定的节点开始运行
|
||||
/// </summary>
|
||||
@@ -1142,14 +1158,6 @@ namespace Serein.Library.Api
|
||||
/// <param name="type">中断类型。0主动监视,1表达式</param>
|
||||
void TriggerInterrupt(string nodeGuid, string expression, InterruptTriggerEventArgs.InterruptTriggerType type);
|
||||
|
||||
/// <summary>
|
||||
/// 立刻调用某个节点,并获取其返回值
|
||||
/// </summary>
|
||||
/// <param name="context">调用时的上下文</param>
|
||||
/// <param name="nodeGuid">节点Guid</param>
|
||||
/// <returns></returns>
|
||||
// Task<object> InvokeNodeAsync(IDynamicContext context, string nodeGuid);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 类库依赖相关
|
||||
|
||||
@@ -32,6 +32,13 @@ namespace Serein.Library.Api
|
||||
/// <returns></returns>
|
||||
ISereinIOC Register(Type type, Func<object> getInstance);
|
||||
|
||||
/// <summary>
|
||||
/// 通过泛型的方式注册实例
|
||||
/// </summary>
|
||||
/// <typeparam name="T">实例类型</typeparam>
|
||||
/// <returns></returns>
|
||||
ISereinIOC Register<T>();
|
||||
|
||||
/// <summary>
|
||||
/// 通过泛型的方式注册实例
|
||||
/// </summary>
|
||||
@@ -84,6 +91,19 @@ namespace Serein.Library.Api
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
ISereinIOC Build();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 从容器中获取某个类型的实例进行运行
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="action"></param>
|
||||
/// <returns></returns>
|
||||
ISereinIOC Run<T>(Action<T> action);
|
||||
ISereinIOC Run<T1, T2>(Action<T1, T2> action);
|
||||
ISereinIOC Run<T1, T2, T3>(Action<T1, T2, T3> action);
|
||||
ISereinIOC Run<T1, T2, T3, T4>(Action<T1, T2, T3, T4> action);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,9 +25,39 @@ namespace Serein.Library
|
||||
var emitMethodType = EmitHelper.CreateDynamicMethod(methodInfo, out var emitDelegate);
|
||||
_emitMethodInfo = emitMethodType;
|
||||
_emitDelegate = emitDelegate;
|
||||
|
||||
SetFunc();
|
||||
}
|
||||
|
||||
|
||||
private void SetFunc()
|
||||
{
|
||||
if (_emitDelegate is Func<object, object[], Task<object>> hasResultTask)
|
||||
{
|
||||
this.hasResultTask = hasResultTask;
|
||||
funcType = 2;
|
||||
}
|
||||
else if (_emitDelegate is Func<object, object[], Task> task)
|
||||
{
|
||||
this.task = task;
|
||||
funcType = 1;
|
||||
}
|
||||
else if (_emitDelegate is Func<object, object[], object> func)
|
||||
{
|
||||
this.func = func;
|
||||
funcType = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Func<object, object[], Task<object>> hasResultTask;
|
||||
public Func<object, object[], Task> task;
|
||||
public Func<object, object[], object> func;
|
||||
|
||||
|
||||
/*/// <summary>
|
||||
/// 更新委托方法
|
||||
@@ -42,6 +72,12 @@ namespace Serein.Library
|
||||
|
||||
private Delegate _emitDelegate;
|
||||
private EmitMethodInfo _emitMethodInfo;
|
||||
/// <summary>
|
||||
/// 0是普通
|
||||
/// 1是异步无返回值
|
||||
/// 2是异步有返回值
|
||||
/// </summary>
|
||||
private int funcType;
|
||||
|
||||
/// <summary>
|
||||
/// 该Emit委托的相应信息
|
||||
@@ -92,34 +128,25 @@ namespace Serein.Library
|
||||
instance = null;
|
||||
}
|
||||
object result = null;
|
||||
if (_emitDelegate is Func<object, object[], Task<object>> hasResultTask)
|
||||
{
|
||||
result = await hasResultTask(instance, args);
|
||||
}
|
||||
else if (_emitDelegate is Func<object, object[], Task> task)
|
||||
{
|
||||
await task.Invoke(instance, args);
|
||||
}
|
||||
else if (_emitDelegate is Func<object, object[], object> func)
|
||||
if(funcType == 0)
|
||||
{
|
||||
result = func.Invoke(instance, args);
|
||||
|
||||
}
|
||||
else if (funcType == 2)
|
||||
{
|
||||
result = await hasResultTask(instance, args);
|
||||
}
|
||||
else if (funcType == 1)
|
||||
{
|
||||
await task(instance, args);
|
||||
result = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException("创建了非预期委托(应该不会出现)");
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
|
||||
//try
|
||||
//{
|
||||
|
||||
//}
|
||||
//catch
|
||||
//{
|
||||
// throw;
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Serein.Library.Utils
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// IOC管理容器
|
||||
/// 一个轻量级的IOC容器
|
||||
/// </summary>
|
||||
public class SereinIOC : ISereinIOC
|
||||
{
|
||||
@@ -79,6 +79,20 @@ namespace Serein.Library.Utils
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 向容器注册类型,并指定其实例成员
|
||||
/// </summary>
|
||||
/// <typeparam name="T">需要注册的类型</typeparam>
|
||||
/// <param name="getInstance">获取实例的回调函数</param>
|
||||
/// <returns></returns>
|
||||
public ISereinIOC Register<T>()
|
||||
{
|
||||
var type = typeof(T);
|
||||
RegisterType(type.FullName, type);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 向容器注册类型,并指定其实例成员
|
||||
/// </summary>
|
||||
@@ -485,7 +499,7 @@ namespace Serein.Library.Utils
|
||||
continue;
|
||||
}
|
||||
_dependencies[typeName] = value;
|
||||
OnIOCMembersChanged.Invoke(new IOCMembersChangedEventArgs(typeName, value));
|
||||
OnIOCMembersChanged?.Invoke(new IOCMembersChangedEventArgs(typeName, value));
|
||||
}
|
||||
_typeMappings.Clear();
|
||||
return this;
|
||||
@@ -577,85 +591,45 @@ namespace Serein.Library.Utils
|
||||
return isPass;
|
||||
}
|
||||
|
||||
|
||||
private void Run<T>(Action<T> action)
|
||||
#endregion
|
||||
|
||||
#region 运行
|
||||
|
||||
public ISereinIOC Run<T>(Action<T> action)
|
||||
{
|
||||
var service = Get<T>();
|
||||
action(service);
|
||||
return this;
|
||||
}
|
||||
|
||||
private void Run<T1, T2>(Action<T1, T2> action)
|
||||
public ISereinIOC Run<T1, T2>(Action<T1, T2> action)
|
||||
{
|
||||
var service1 = Get<T1>();
|
||||
var service2 = Get<T2>();
|
||||
|
||||
action(service1, service2);
|
||||
action(service1, service2);
|
||||
return this;
|
||||
}
|
||||
|
||||
private void Run<T1, T2, T3>(Action<T1, T2, T3> action)
|
||||
public ISereinIOC Run<T1, T2, T3>(Action<T1, T2, T3> action)
|
||||
{
|
||||
var service1 = Get<T1>();
|
||||
var service2 = Get<T2>();
|
||||
var service3 = Get<T3>();
|
||||
action(service1, service2, service3);
|
||||
return this;
|
||||
}
|
||||
|
||||
private void Run<T1, T2, T3, T4>(Action<T1, T2, T3, T4> action)
|
||||
public ISereinIOC Run<T1, T2, T3, T4>(Action<T1, T2, T3, T4> action)
|
||||
{
|
||||
var service1 = Get<T1>();
|
||||
var service2 = Get<T2>();
|
||||
var service3 = Get<T3>();
|
||||
var service4 = Get<T4>();
|
||||
action(service1, service2, service3, service4);
|
||||
return this;
|
||||
}
|
||||
|
||||
private void Run<T1, T2, T3, T4, T5>(Action<T1, T2, T3, T4, T5> action)
|
||||
{
|
||||
var service1 = Get<T1>();
|
||||
var service2 = Get<T2>();
|
||||
var service3 = Get<T3>();
|
||||
var service4 = Get<T4>();
|
||||
var service5 = Get<T5>();
|
||||
action(service1, service2, service3, service4, service5);
|
||||
}
|
||||
|
||||
private void Run<T1, T2, T3, T4, T5, T6>(Action<T1, T2, T3, T4, T5, T6> action)
|
||||
{
|
||||
var service1 = Get<T1>();
|
||||
var service2 = Get<T2>();
|
||||
var service3 = Get<T3>();
|
||||
var service4 = Get<T4>();
|
||||
var service5 = Get<T5>();
|
||||
var service6 = Get<T6>();
|
||||
action(service1, service2, service3, service4, service5, service6);
|
||||
}
|
||||
|
||||
private void Run<T1, T2, T3, T4, T5, T6, T7>(Action<T1, T2, T3, T4, T5, T6, T7> action)
|
||||
{
|
||||
var service1 = Get<T1>();
|
||||
var service2 = Get<T2>();
|
||||
var service3 = Get<T3>();
|
||||
var service4 = Get<T4>();
|
||||
var service5 = Get<T5>();
|
||||
var service6 = Get<T6>();
|
||||
var service7 = Get<T7>();
|
||||
action(service1, service2, service3, service4, service5, service6, service7);
|
||||
}
|
||||
|
||||
private void Run<T1, T2, T3, T4, T5, T6, T7, T8>(Action<T1, T2, T3, T4, T5, T6, T7, T8> action)
|
||||
{
|
||||
var service1 = Get<T1>();
|
||||
var service2 = Get<T2>();
|
||||
var service3 = Get<T3>();
|
||||
var service4 = Get<T4>();
|
||||
var service5 = Get<T5>();
|
||||
var service6 = Get<T6>();
|
||||
var service7 = Get<T7>();
|
||||
var service8 = Get<T8>();
|
||||
action(service1, service2, service3, service4, service5, service6, service7, service8);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
@@ -45,9 +45,9 @@ namespace Serein.Library.Utils
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 传入UI线程上下文
|
||||
/// 传入获取UI线程上下文的闭包创建
|
||||
/// </summary>
|
||||
/// <param name="synchronizationContext">线程上下文</param>
|
||||
/// <param name="getUiContext">获取线程上下文的闭包函数</param>
|
||||
public UIContextOperation(Func<SynchronizationContext> getUiContext)
|
||||
{
|
||||
this.getUiContext = getUiContext;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,710 +0,0 @@
|
||||
using Serein.Library;
|
||||
using Serein.Library.Api;
|
||||
using Serein.Library.FlowNode;
|
||||
using Serein.Library.Utils;
|
||||
using Serein.NodeFlow.Tool;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Serein.NodeFlow.Env
|
||||
{
|
||||
/// <summary>
|
||||
/// 自动管理本地与远程的环境
|
||||
/// </summary>
|
||||
public class FlowEnvironmentDecorator : IFlowEnvironment, IFlowEnvironmentEvent, ISereinIOC
|
||||
{
|
||||
public FlowEnvironmentDecorator()
|
||||
{
|
||||
flowEnvironment = new FlowEnvironment();
|
||||
// 默认使用本地环境
|
||||
currentFlowEnvironment = flowEnvironment;
|
||||
currentFlowEnvironmentEvent = flowEnvironment;
|
||||
SereinEnv.SetEnv(currentFlowEnvironment);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 本地环境
|
||||
/// </summary>
|
||||
private readonly FlowEnvironment flowEnvironment;
|
||||
|
||||
/// <summary>
|
||||
/// 远程环境
|
||||
/// </summary>
|
||||
private RemoteFlowEnvironment remoteFlowEnvironment;
|
||||
|
||||
/// <summary>
|
||||
/// 本地环境事件
|
||||
/// </summary>
|
||||
private readonly IFlowEnvironmentEvent flowEnvironmentEvent;
|
||||
|
||||
/// <summary>
|
||||
/// 远程环境事件
|
||||
/// </summary>
|
||||
private IFlowEnvironmentEvent remoteFlowEnvironmentEvent;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 管理当前环境
|
||||
/// </summary>
|
||||
|
||||
private IFlowEnvironment currentFlowEnvironment;
|
||||
|
||||
/// <summary>
|
||||
/// 管理当前环境事件
|
||||
/// </summary>
|
||||
private IFlowEnvironmentEvent currentFlowEnvironmentEvent;
|
||||
|
||||
|
||||
|
||||
private int _loadingProjectFlag = 0; // 使用原子自增代替锁
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 传入false时,将停止数据通知。传入true时,
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void SetProjectLoadingFlag(bool value)
|
||||
{
|
||||
Interlocked.Exchange(ref _loadingProjectFlag, value ? 1 : 0);
|
||||
}
|
||||
/// <summary>
|
||||
/// 判断是否正在加载项目
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsLoadingProject()
|
||||
{
|
||||
return Interlocked.CompareExchange(ref _loadingProjectFlag, 1, 1) == 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 当前环境,用于切换远程与本地环境
|
||||
/// </summary>
|
||||
public IFlowEnvironment CurrentEnv { get => currentFlowEnvironment; }
|
||||
|
||||
public UIContextOperation UIContextOperation => currentFlowEnvironment.UIContextOperation;
|
||||
/// <summary>
|
||||
/// 节点视图模型管理类
|
||||
/// </summary>
|
||||
public NodeMVVMManagement NodeMVVMManagement => currentFlowEnvironment.NodeMVVMManagement;
|
||||
|
||||
public ISereinIOC IOC => (ISereinIOC)currentFlowEnvironment;
|
||||
|
||||
|
||||
public string EnvName => currentFlowEnvironment.EnvName;
|
||||
public string ProjectFileLocation => currentFlowEnvironment.EnvName;
|
||||
|
||||
public bool IsGlobalInterrupt => currentFlowEnvironment.IsGlobalInterrupt;
|
||||
|
||||
public bool IsControlRemoteEnv => currentFlowEnvironment.IsControlRemoteEnv;
|
||||
|
||||
/// <summary>
|
||||
/// 信息输出等级
|
||||
/// </summary>
|
||||
public InfoClass InfoClass { get => currentFlowEnvironment.InfoClass; set => currentFlowEnvironment.InfoClass = value; }
|
||||
public RunState FlowState { get => currentFlowEnvironment.FlowState; set => currentFlowEnvironment.FlowState = value; }
|
||||
//public RunState FlipFlopState { get => currentFlowEnvironment.FlipFlopState; set => currentFlowEnvironment.FlipFlopState = value; }
|
||||
|
||||
public event LoadDllHandler OnDllLoad {
|
||||
add { currentFlowEnvironmentEvent.OnDllLoad += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnDllLoad -= value; }
|
||||
}
|
||||
|
||||
public event ProjectLoadedHandler OnProjectLoaded
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnProjectLoaded += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnProjectLoaded -= value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 项目准备保存
|
||||
/// </summary>
|
||||
public event ProjectSavingHandler? OnProjectSaving
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnProjectSaving += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnProjectSaving -= value; }
|
||||
}
|
||||
|
||||
|
||||
public event NodeConnectChangeHandler OnNodeConnectChange
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnNodeConnectChange += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnNodeConnectChange -= value; }
|
||||
}
|
||||
|
||||
|
||||
public event CanvasCreateHandler OnCanvasCreate
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnCanvasCreate += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnCanvasCreate -= value; }
|
||||
}
|
||||
public event CanvasRemoveHandler OnCanvasRemove
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnCanvasRemove += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnCanvasRemove -= value; }
|
||||
}
|
||||
|
||||
public event NodeCreateHandler OnNodeCreate
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnNodeCreate += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnNodeCreate -= value; }
|
||||
}
|
||||
|
||||
public event NodeRemoveHandler OnNodeRemove
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnNodeRemove += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnNodeRemove -= value; }
|
||||
}
|
||||
|
||||
public event NodePlaceHandler OnNodePlace
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnNodePlace += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnNodePlace -= value; }
|
||||
}
|
||||
|
||||
public event NodeTakeOutHandler OnNodeTakeOut
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnNodeTakeOut += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnNodeTakeOut -= value; }
|
||||
}
|
||||
|
||||
public event StartNodeChangeHandler OnStartNodeChange
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnStartNodeChange += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnStartNodeChange -= value; }
|
||||
}
|
||||
|
||||
public event FlowRunCompleteHandler OnFlowRunComplete
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnFlowRunComplete += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnFlowRunComplete -= value; }
|
||||
}
|
||||
|
||||
public event MonitorObjectChangeHandler OnMonitorObjectChange
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnMonitorObjectChange += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnMonitorObjectChange -= value; }
|
||||
}
|
||||
|
||||
public event NodeInterruptStateChangeHandler OnNodeInterruptStateChange
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnNodeInterruptStateChange += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnNodeInterruptStateChange -= value; }
|
||||
}
|
||||
|
||||
public event ExpInterruptTriggerHandler OnInterruptTrigger
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnInterruptTrigger += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnInterruptTrigger -= value; }
|
||||
}
|
||||
|
||||
public event IOCMembersChangedHandler OnIOCMembersChanged
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnIOCMembersChanged += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnIOCMembersChanged -= value; }
|
||||
}
|
||||
|
||||
public event NodeLocatedHandler OnNodeLocated
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnNodeLocated += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnNodeLocated -= value; }
|
||||
}
|
||||
|
||||
public event NodeMovedHandler OnNodeMoved
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnNodeMoved += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnNodeMoved -= value; }
|
||||
}
|
||||
|
||||
public event EnvOutHandler OnEnvOut
|
||||
{
|
||||
add { currentFlowEnvironmentEvent.OnEnvOut += value; }
|
||||
remove { currentFlowEnvironmentEvent.OnEnvOut -= value; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void ActivateFlipflopNode(string nodeGuid)
|
||||
{
|
||||
currentFlowEnvironment.ActivateFlipflopNode(nodeGuid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加画布
|
||||
/// </summary>
|
||||
/// <param name="canvasName">画布名称</param>
|
||||
/// <param name="width">宽度</param>
|
||||
/// <param name="height">高度</param>
|
||||
/// <returns></returns>
|
||||
public async Task<FlowCanvasDetailsInfo> CreateCanvasAsync(string canvasName, int width, int height)
|
||||
{
|
||||
return await currentFlowEnvironment.CreateCanvasAsync(canvasName, width, height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除画布
|
||||
/// </summary>
|
||||
/// <param name="canvasGuid">画布Guid</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> RemoveCanvasAsync(string canvasGuid)
|
||||
{
|
||||
return await currentFlowEnvironment.RemoveCanvasAsync(canvasGuid);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 在两个节点之间创建连接关系
|
||||
/// </summary>
|
||||
/// <param name="fromNodeGuid">起始节点Guid</param>
|
||||
/// <param name="toNodeGuid">目标节点Guid</param>
|
||||
/// <param name="fromNodeJunctionType">起始节点控制点</param>
|
||||
/// <param name="toNodeJunctionType">目标节点控制点</param>
|
||||
/// <param name="invokeType">决定了方法执行后的后继行为</param>
|
||||
public async Task<bool> ConnectInvokeNodeAsync(string canvasGuid,
|
||||
string fromNodeGuid,
|
||||
string toNodeGuid,
|
||||
JunctionType fromNodeJunctionType,
|
||||
JunctionType toNodeJunctionType,
|
||||
ConnectionInvokeType invokeType)
|
||||
{
|
||||
return await currentFlowEnvironment.ConnectInvokeNodeAsync(canvasGuid, fromNodeGuid, toNodeGuid, fromNodeJunctionType, toNodeJunctionType, invokeType);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 在两个节点之间创建连接关系
|
||||
/// </summary>
|
||||
/// <param name="fromNodeGuid">起始节点Guid</param>
|
||||
/// <param name="toNodeGuid">目标节点Guid</param>
|
||||
/// <param name="fromNodeJunctionType">起始节点控制点</param>
|
||||
/// <param name="toNodeJunctionType">目标节点控制点</param>
|
||||
/// <param name="argSourceType">决定了方法参数来源</param>
|
||||
/// <param name="argIndex">设置第几个参数</param>
|
||||
public async Task<bool> ConnectArgSourceNodeAsync(string canvasGuid,
|
||||
string fromNodeGuid,
|
||||
string toNodeGuid,
|
||||
JunctionType fromNodeJunctionType,
|
||||
JunctionType toNodeJunctionType,
|
||||
ConnectionArgSourceType argSourceType,
|
||||
int argIndex)
|
||||
{
|
||||
return await currentFlowEnvironment.ConnectArgSourceNodeAsync(canvasGuid, fromNodeGuid, toNodeGuid, fromNodeJunctionType, toNodeJunctionType, argSourceType, argIndex);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 连接远程环境并自动切换环境
|
||||
/// </summary>
|
||||
/// <param name="addres"></param>
|
||||
/// <param name="port"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<(bool, RemoteMsgUtil)> ConnectRemoteEnv(string addres, int port, string token)
|
||||
{
|
||||
// 连接成功,切换远程环境
|
||||
(var isConnect, var remoteMsgUtil) = await currentFlowEnvironment.ConnectRemoteEnv(addres, port, token);
|
||||
if (isConnect)
|
||||
{
|
||||
|
||||
remoteFlowEnvironment ??= new RemoteFlowEnvironment(remoteMsgUtil, this.UIContextOperation);
|
||||
currentFlowEnvironment = remoteFlowEnvironment;
|
||||
}
|
||||
return (isConnect, remoteMsgUtil);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从节点信息集合批量加载节点控件
|
||||
/// </summary>
|
||||
/// <param name="List<NodeInfo>">节点信息</param>
|
||||
/// <param name="position">需要加载的位置</param>
|
||||
/// <returns></returns>
|
||||
public async Task LoadNodeInfosAsync(List<NodeInfo> nodeInfos)
|
||||
{
|
||||
SetProjectLoadingFlag(false);
|
||||
await currentFlowEnvironment.LoadNodeInfosAsync(nodeInfos); // 装饰器调用
|
||||
SetProjectLoadingFlag(true);
|
||||
}
|
||||
|
||||
public async Task<NodeInfo> CreateNodeAsync(string canvasGuid, NodeControlType nodeBase, PositionOfUI position, MethodDetailsInfo methodDetailsInfo = null)
|
||||
{
|
||||
SetProjectLoadingFlag(false);
|
||||
var result = await currentFlowEnvironment.CreateNodeAsync(canvasGuid, nodeBase, position, methodDetailsInfo); // 装饰器调用
|
||||
SetProjectLoadingFlag(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 将节点放置在容器中
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> PlaceNodeToContainerAsync(string canvasGuid, string nodeGuid, string containerNodeGuid)
|
||||
{
|
||||
SetProjectLoadingFlag(false);
|
||||
var result = await currentFlowEnvironment.PlaceNodeToContainerAsync(canvasGuid, nodeGuid, containerNodeGuid); // 装饰器调用
|
||||
SetProjectLoadingFlag(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将节点从容器中脱离
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> TakeOutNodeToContainerAsync(string canvasGuid, string nodeGuid)
|
||||
{
|
||||
SetProjectLoadingFlag(false);
|
||||
var result = await currentFlowEnvironment.TakeOutNodeToContainerAsync(canvasGuid,nodeGuid); // 装饰器调用
|
||||
SetProjectLoadingFlag(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public async Task<bool> ExitFlowAsync()
|
||||
{
|
||||
return await currentFlowEnvironment.ExitFlowAsync();
|
||||
}
|
||||
|
||||
public void ExitRemoteEnv()
|
||||
{
|
||||
currentFlowEnvironment.ExitRemoteEnv();
|
||||
}
|
||||
|
||||
|
||||
public async Task<FlowEnvInfo> GetEnvInfoAsync()
|
||||
{
|
||||
return await currentFlowEnvironment.GetEnvInfoAsync();
|
||||
}
|
||||
|
||||
|
||||
public async Task<SereinProjectData> GetProjectInfoAsync()
|
||||
{
|
||||
return await currentFlowEnvironment.GetProjectInfoAsync();
|
||||
}
|
||||
|
||||
|
||||
public void LoadLibrary(string dllPath)
|
||||
{
|
||||
currentFlowEnvironment.LoadLibrary(dllPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存项目
|
||||
/// </summary>
|
||||
public void SaveProject()
|
||||
{
|
||||
currentFlowEnvironment.SaveProject();
|
||||
}
|
||||
|
||||
public void LoadProject(FlowEnvInfo flowEnvInfo, string filePath)
|
||||
{
|
||||
if (flowEnvInfo is null) return;
|
||||
SetProjectLoadingFlag(false);
|
||||
currentFlowEnvironment.LoadProject(flowEnvInfo, filePath);
|
||||
SetProjectLoadingFlag(true);
|
||||
}
|
||||
|
||||
public void MonitorObjectNotification(string nodeGuid, object monitorData, MonitorObjectEventArgs.ObjSourceType sourceType)
|
||||
{
|
||||
currentFlowEnvironment.MonitorObjectNotification(nodeGuid, monitorData, sourceType);
|
||||
}
|
||||
|
||||
public void MoveNode(string canvasGuid, string nodeGuid, double x, double y)
|
||||
{
|
||||
currentFlowEnvironment.MoveNode(canvasGuid, nodeGuid, x, y);
|
||||
}
|
||||
|
||||
public void NodeLocated(string nodeGuid)
|
||||
{
|
||||
currentFlowEnvironment.NodeLocated(nodeGuid);
|
||||
}
|
||||
|
||||
|
||||
public bool TryUnloadLibrary(string assemblyName)
|
||||
{
|
||||
return currentFlowEnvironment.TryUnloadLibrary(assemblyName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置两个节点某个类型的方法调用关系为优先调用
|
||||
/// </summary>
|
||||
/// <param name="fromNodeGuid">起始节点</param>
|
||||
/// <param name="toNodeGuid">目标节点</param>
|
||||
/// <param name="connectionType">连接关系</param>
|
||||
/// <returns>是否成功调用</returns>
|
||||
public async Task<bool> SetConnectPriorityInvoke(string fromNodeGuid, string toNodeGuid, ConnectionInvokeType connectionType)
|
||||
{
|
||||
return await currentFlowEnvironment.SetConnectPriorityInvoke(fromNodeGuid, toNodeGuid, connectionType);
|
||||
}
|
||||
/// <summary>
|
||||
/// 移除方法调用关系
|
||||
/// </summary>
|
||||
/// <param name="fromNodeGuid"></param>
|
||||
/// <param name="toNodeGuid"></param>
|
||||
/// <param name="connectionType"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> RemoveConnectInvokeAsync(string canvasGuid, string fromNodeGuid, string toNodeGuid, ConnectionInvokeType connectionType)
|
||||
{
|
||||
return await currentFlowEnvironment.RemoveConnectInvokeAsync(canvasGuid, fromNodeGuid, toNodeGuid, connectionType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除连接节点之间参数传递的关系
|
||||
/// </summary>
|
||||
/// <param name="fromNodeGuid">起始节点Guid</param>
|
||||
/// <param name="toNodeGuid">目标节点Guid</param>
|
||||
/// <param name="argIndex">连接到第几个参数</param>
|
||||
/// <param name="connectionArgSourceType">参数来源类型</param>
|
||||
public async Task<bool> RemoveConnectArgSourceAsync(string canvasGuid, string fromNodeGuid, string toNodeGuid, int argIndex)
|
||||
{
|
||||
return await currentFlowEnvironment.RemoveConnectArgSourceAsync(canvasGuid, fromNodeGuid, toNodeGuid, argIndex);
|
||||
}
|
||||
|
||||
public async Task<bool> RemoveNodeAsync(string canvasGuid, string nodeGuid)
|
||||
{
|
||||
return await currentFlowEnvironment.RemoveNodeAsync(canvasGuid, nodeGuid);
|
||||
}
|
||||
|
||||
|
||||
//public void SetConsoleOut()
|
||||
//{
|
||||
// currentFlowEnvironment.SetConsoleOut();
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 输出信息
|
||||
/// </summary>
|
||||
/// <param name="message">日志内容</param>
|
||||
/// <param name="type">日志类别</param>
|
||||
/// <param name="class">日志级别</param>
|
||||
public void WriteLine(InfoType type, string message, InfoClass @class = InfoClass.Trivial)
|
||||
{
|
||||
currentFlowEnvironment.WriteLine(type, message, @class);
|
||||
}
|
||||
|
||||
|
||||
#region MyRegion
|
||||
#if false
|
||||
public async Task<bool> AddInterruptExpressionAsync(string key, string expression)
|
||||
{
|
||||
return await currentFlowEnvironment.AddInterruptExpressionAsync(key, expression);
|
||||
}
|
||||
|
||||
|
||||
public async Task<(bool, string[])> CheckObjMonitorStateAsync(string key)
|
||||
{
|
||||
return await currentFlowEnvironment.CheckObjMonitorStateAsync(key);
|
||||
}
|
||||
public async Task<ChannelFlowInterrupt.CancelType> GetOrCreateGlobalInterruptAsync()
|
||||
{
|
||||
return await currentFlowEnvironment.InterruptNode();
|
||||
}
|
||||
|
||||
public void SetMonitorObjState(string key, bool isMonitor)
|
||||
{
|
||||
currentFlowEnvironment.SetMonitorObjState(key, isMonitor);
|
||||
}
|
||||
|
||||
public async Task<bool> SetNodeInterruptAsync(string nodeGuid, bool isInterrupt)
|
||||
{
|
||||
return await currentFlowEnvironment.SetNodeInterruptAsync(nodeGuid, isInterrupt);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
public async Task<string> SetStartNodeAsync(string canvasGuid, string nodeGuid)
|
||||
{
|
||||
return await currentFlowEnvironment.SetStartNodeAsync(canvasGuid, nodeGuid);
|
||||
}
|
||||
|
||||
public async Task<bool> StartFlowAsync(string[] canvasGuids)
|
||||
{
|
||||
return await currentFlowEnvironment.StartFlowAsync(canvasGuids);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<bool> StartFlowFromSelectNodeAsync(string startNodeGuid)
|
||||
{
|
||||
return await currentFlowEnvironment.StartFlowFromSelectNodeAsync(startNodeGuid);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task StartRemoteServerAsync(int port = 7525)
|
||||
{
|
||||
await currentFlowEnvironment.StartRemoteServerAsync(port);
|
||||
}
|
||||
|
||||
public void StopRemoteServer()
|
||||
{
|
||||
currentFlowEnvironment.StopRemoteServer();
|
||||
}
|
||||
|
||||
public void TerminateFlipflopNode(string nodeGuid)
|
||||
{
|
||||
currentFlowEnvironment.TerminateFlipflopNode(nodeGuid);
|
||||
}
|
||||
|
||||
public void TriggerInterrupt(string nodeGuid, string expression, InterruptTriggerEventArgs.InterruptTriggerType type)
|
||||
{
|
||||
currentFlowEnvironment.TriggerInterrupt(nodeGuid, expression, type);
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置在UI线程操作的线程上下文
|
||||
/// </summary>
|
||||
/// <param name="uiContextOperation"></param>
|
||||
public void SetUIContextOperation(UIContextOperation uiContextOperation)
|
||||
{
|
||||
currentFlowEnvironment.SetUIContextOperation(uiContextOperation);
|
||||
}
|
||||
|
||||
public bool TryGetNodeModel(string nodeGuid, out IFlowNode nodeModel)
|
||||
{
|
||||
return currentFlowEnvironment.TryGetNodeModel(nodeGuid, out nodeModel);
|
||||
}
|
||||
public bool TryGetDelegateDetails(string libraryName, string methodName, out DelegateDetails del)
|
||||
{
|
||||
return currentFlowEnvironment.TryGetDelegateDetails(libraryName, methodName, out del);
|
||||
}
|
||||
|
||||
public bool TryGetMethodDetailsInfo(string libraryName, string methodName, out MethodDetailsInfo mdInfo)
|
||||
{
|
||||
return currentFlowEnvironment.TryGetMethodDetailsInfo(libraryName, methodName, out mdInfo);
|
||||
}
|
||||
|
||||
//public void WriteLineObjToJson(object obj)
|
||||
//{
|
||||
// currentFlowEnvironment.WriteLineObjToJson(obj);
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// (用于远程)通知节点属性变更
|
||||
/// </summary>
|
||||
/// <param name="nodeGuid">节点Guid</param>
|
||||
/// <param name="path">属性路径</param>
|
||||
/// <param name="value">属性值</param>
|
||||
/// <returns></returns>
|
||||
public async Task NotificationNodeValueChangeAsync(string nodeGuid, string path, object value)
|
||||
{
|
||||
if (!IsLoadingProject())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (currentFlowEnvironment.IsControlRemoteEnv)
|
||||
{
|
||||
await currentFlowEnvironment.NotificationNodeValueChangeAsync(nodeGuid, path, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 改变可选参数的数目
|
||||
/// </summary>
|
||||
/// <param name="nodeGuid">对应的节点Guid</param>
|
||||
/// <param name="isAdd">true,增加参数;false,减少参数</param>
|
||||
/// <param name="paramIndex">以哪个参数为模板进行拷贝,或删去某个参数(该参数必须为可选参数)</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> ChangeParameter(string nodeGuid, bool isAdd, int paramIndex)
|
||||
{
|
||||
return await currentFlowEnvironment.ChangeParameter(nodeGuid, isAdd, paramIndex);
|
||||
}
|
||||
|
||||
#region 流程依赖类库的接口
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 运行时加载
|
||||
/// </summary>
|
||||
/// <param name="file">文件名</param>
|
||||
/// <returns></returns>
|
||||
public bool LoadNativeLibraryOfRuning(string file)
|
||||
{
|
||||
return currentFlowEnvironment.LoadNativeLibraryOfRuning(file);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 运行时加载指定目录下的类库
|
||||
/// </summary>
|
||||
/// <param name="path">目录</param>
|
||||
/// <param name="isRecurrence">是否递归加载</param>
|
||||
public void LoadAllNativeLibraryOfRuning(string path, bool isRecurrence = true)
|
||||
{
|
||||
currentFlowEnvironment.LoadAllNativeLibraryOfRuning(path,isRecurrence);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IOC容器
|
||||
public ISereinIOC Build()
|
||||
{
|
||||
return IOC.Build();
|
||||
}
|
||||
|
||||
//public bool RegisterInstance(string key, object instance)
|
||||
//{
|
||||
// return IOC.RegisterInstance(key, instance);
|
||||
//}
|
||||
|
||||
public object Get(Type type)
|
||||
{
|
||||
return IOC.Get(type);
|
||||
}
|
||||
|
||||
public T Get<T>()
|
||||
{
|
||||
return IOC.Get<T>();
|
||||
}
|
||||
|
||||
//public T Get<T>(string key)
|
||||
//{
|
||||
// return IOC.Get<T>(key);
|
||||
//}
|
||||
|
||||
public object CreateTempObject(Type type)
|
||||
{
|
||||
return IOC.CreateTempObject(type);
|
||||
}
|
||||
|
||||
public T CreateTempObject<T>()
|
||||
{
|
||||
return IOC.CreateTempObject<T>();
|
||||
}
|
||||
|
||||
public ISereinIOC Register(Type type)
|
||||
{
|
||||
return IOC.Register(type);
|
||||
}
|
||||
|
||||
public ISereinIOC Register(Type type, Func<object> getInstance)
|
||||
{
|
||||
return IOC.Register(type, getInstance);
|
||||
}
|
||||
|
||||
public ISereinIOC Register<T>(Func<T> getInstance)
|
||||
{
|
||||
return IOC.Register<T>(getInstance);
|
||||
}
|
||||
|
||||
public ISereinIOC Register<TService, TImplementation>(Func<TService> getInstance) where TImplementation : TService
|
||||
{
|
||||
return IOC.Register<TService, TImplementation>(getInstance);
|
||||
}
|
||||
|
||||
public ISereinIOC Register<TService, TImplementation>() where TImplementation : TService
|
||||
{
|
||||
return IOC.Register<TService, TImplementation>();
|
||||
}
|
||||
|
||||
public ISereinIOC Reset()
|
||||
{
|
||||
return IOC.Reset();
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
2213
NodeFlow/Env/LocalFlowEnvironment.cs
Normal file
2213
NodeFlow/Env/LocalFlowEnvironment.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -10,9 +10,9 @@ namespace Serein.NodeFlow.Env
|
||||
/// 客户端的消息管理(用于处理服务端的响应)
|
||||
/// </summary>
|
||||
|
||||
[AutoSocketModule(ThemeKey = FlowEnvironment.ThemeKey,
|
||||
DataKey = FlowEnvironment.DataKey,
|
||||
MsgIdKey = FlowEnvironment.MsgIdKey)]
|
||||
[AutoSocketModule(ThemeKey = LocalFlowEnvironment.ThemeKey,
|
||||
DataKey = LocalFlowEnvironment.DataKey,
|
||||
MsgIdKey = LocalFlowEnvironment.MsgIdKey)]
|
||||
public class MsgControllerOfClient : ISocketHandleModule
|
||||
{
|
||||
public Guid HandleGuid => new Guid();
|
||||
|
||||
@@ -11,9 +11,9 @@ namespace Serein.NodeFlow.Env
|
||||
/// <summary>
|
||||
/// 服务端的消息管理(用于处理客户端的请求)
|
||||
/// </summary>
|
||||
[AutoSocketModule(ThemeKey = FlowEnvironment.ThemeKey,
|
||||
DataKey = FlowEnvironment.DataKey,
|
||||
MsgIdKey = FlowEnvironment.MsgIdKey)]
|
||||
[AutoSocketModule(ThemeKey = LocalFlowEnvironment.ThemeKey,
|
||||
DataKey = LocalFlowEnvironment.DataKey,
|
||||
MsgIdKey = LocalFlowEnvironment.MsgIdKey)]
|
||||
public class MsgControllerOfServer : ISocketHandleModule
|
||||
{
|
||||
/// <summary>
|
||||
@@ -156,8 +156,8 @@ namespace Serein.NodeFlow.Env
|
||||
{
|
||||
JObject sendJson = new JObject
|
||||
{
|
||||
[FlowEnvironment.ThemeKey] = theme,
|
||||
[FlowEnvironment.DataKey] = JObject.FromObject(data),
|
||||
[LocalFlowEnvironment.ThemeKey] = theme,
|
||||
[LocalFlowEnvironment.DataKey] = JObject.FromObject(data),
|
||||
};
|
||||
var msg = sendJson.ToString();
|
||||
await SendAsync(msg);
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Serein.NodeFlow.Env
|
||||
|
||||
public ISereinIOC IOC => throw new NotImplementedException();
|
||||
|
||||
public string EnvName => FlowEnvironment.SpaceName;
|
||||
public string EnvName => LocalFlowEnvironment.SpaceName;
|
||||
|
||||
/// <summary>
|
||||
/// 远程项目的网络位置(WebSocket + IP + 端口 : 远程主机的文件路径)
|
||||
@@ -1424,6 +1424,11 @@ namespace Serein.NodeFlow.Env
|
||||
this.WriteLine(InfoType.INFO, "远程环境尚未实现的接口:LoadAllNativeLibraryOfRuning");
|
||||
}
|
||||
|
||||
public void UseExternalIOC(ISereinIOC ioc)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -22,19 +22,19 @@ namespace Serein.Workbench
|
||||
/// <param name="collection"></param>
|
||||
public static void AddViewModelServices(this IServiceCollection collection)
|
||||
{
|
||||
collection.AddSingleton<Locator>(); // 主窗体
|
||||
collection.AddSingleton<Locator>(); // 视图模型路由
|
||||
|
||||
collection.AddSingleton<MainViewModel>();
|
||||
collection.AddSingleton<MainMenuBarViewModel>();
|
||||
collection.AddSingleton<FlowWorkbenchViewModel>();
|
||||
collection.AddSingleton<BaseNodesViewModel>();
|
||||
collection.AddSingleton<FlowLibrarysViewModel>();
|
||||
collection.AddSingleton<FlowEditViewModel>();
|
||||
collection.AddSingleton<ViewNodeInfoViewModel>();
|
||||
collection.AddSingleton<ViewNodeMethodInfoViewModel>();
|
||||
collection.AddSingleton<MainViewModel>();
|
||||
collection.AddSingleton<MainMenuBarViewModel>(); // 菜单栏视图模型
|
||||
collection.AddSingleton<FlowWorkbenchViewModel>(); // 工作台视图模型
|
||||
collection.AddSingleton<BaseNodesViewModel>(); // 基础节点视图模型
|
||||
collection.AddSingleton<FlowLibrarysViewModel>(); // 流程已加载依赖视图模型
|
||||
collection.AddSingleton<FlowEditViewModel>(); // 流程画布编辑器视图模型
|
||||
collection.AddSingleton<ViewNodeInfoViewModel>(); // 节点信息视图模型
|
||||
collection.AddSingleton<ViewNodeMethodInfoViewModel>(); // 方法信息视图模型
|
||||
collection.AddSingleton<ViewCanvasInfoViewModel>(); // 画布视图模型
|
||||
|
||||
collection.AddTransient<FlowCanvasViewModel>(); // 画布
|
||||
collection.AddTransient<ViewCanvasInfoViewModel>(); // 画布节点树视图
|
||||
}
|
||||
|
||||
public static void AddWorkbenchServices(this IServiceCollection collection)
|
||||
@@ -54,7 +54,7 @@ namespace Serein.Workbench
|
||||
public static void AddFlowServices(this IServiceCollection collection)
|
||||
{
|
||||
#region 创建实例
|
||||
Func<SynchronizationContext> getSyncContext = null;
|
||||
Func<SynchronizationContext>? getSyncContext = null;
|
||||
Dispatcher.CurrentDispatcher.Invoke(() =>
|
||||
{
|
||||
var uiContext = SynchronizationContext.Current; // 在UI线程上获取UI线程上下文信息
|
||||
@@ -62,16 +62,14 @@ namespace Serein.Workbench
|
||||
{
|
||||
getSyncContext = () => uiContext;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
UIContextOperation? uIContextOperation = null;
|
||||
uIContextOperation = new UIContextOperation(getSyncContext); // 封装一个调用UI线程的工具类
|
||||
var flowEnvironmentDecorator = new FlowEnvironmentDecorator();
|
||||
flowEnvironmentDecorator.SetUIContextOperation(uIContextOperation);
|
||||
var flowEnvironment = new FlowEnvironment();
|
||||
flowEnvironment.SetUIContextOperation(uIContextOperation);
|
||||
collection.AddSingleton<UIContextOperation>(uIContextOperation); // 注册UI线程操作上下文
|
||||
collection.AddSingleton<IFlowEnvironment>(flowEnvironmentDecorator); // 注册运行环境
|
||||
collection.AddSingleton<IFlowEnvironmentEvent>(flowEnvironmentDecorator); // 注册运行环境事件
|
||||
collection.AddSingleton<IFlowEnvironment>(flowEnvironment); // 注册运行环境
|
||||
collection.AddSingleton<IFlowEnvironmentEvent>(flowEnvironment); // 注册运行环境事件
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace Serein.Workbench.Services
|
||||
private void InitFlowEnvironmentEvent()
|
||||
{
|
||||
flowEnvironmentEvent.OnDllLoad += FlowEnvironment_DllLoadEvent;
|
||||
flowEnvironmentEvent.OnProjectSaving += EnvDecorator_OnProjectSaving;
|
||||
flowEnvironmentEvent.OnProjectSaving += FlowEnvironment_OnProjectSaving;
|
||||
flowEnvironmentEvent.OnProjectLoaded += FlowEnvironment_OnProjectLoaded;
|
||||
flowEnvironmentEvent.OnCanvasCreate += FlowEnvironmentEvent_OnCanvasCreate;
|
||||
flowEnvironmentEvent.OnCanvasRemove += FlowEnvironmentEvent_OnCanvasRemove;
|
||||
@@ -138,8 +138,8 @@ namespace Serein.Workbench.Services
|
||||
flowEnvironmentEvent.OnNodeConnectChange += FlowEnvironment_NodeConnectChangeEvemt;
|
||||
flowEnvironmentEvent.OnNodeCreate += FlowEnvironment_NodeCreateEvent;
|
||||
flowEnvironmentEvent.OnNodeRemove += FlowEnvironment_NodeRemoveEvent;
|
||||
flowEnvironmentEvent.OnNodePlace += EnvDecorator_OnNodePlaceEvent;
|
||||
flowEnvironmentEvent.OnNodeTakeOut += EnvDecorator_OnNodeTakeOutEvent;
|
||||
flowEnvironmentEvent.OnNodePlace += FlowEnvironment_OnNodePlaceEvent;
|
||||
flowEnvironmentEvent.OnNodeTakeOut += FlowEnvironment_OnNodeTakeOutEvent;
|
||||
flowEnvironmentEvent.OnFlowRunComplete += FlowEnvironment_OnFlowRunCompleteEvent;
|
||||
|
||||
flowEnvironmentEvent.OnMonitorObjectChange += FlowEnvironment_OnMonitorObjectChangeEvent;
|
||||
@@ -158,14 +158,14 @@ namespace Serein.Workbench.Services
|
||||
private void ResetFlowEnvironmentEvent()
|
||||
{
|
||||
flowEnvironmentEvent.OnDllLoad -= FlowEnvironment_DllLoadEvent;
|
||||
flowEnvironmentEvent.OnProjectSaving -= EnvDecorator_OnProjectSaving;
|
||||
flowEnvironmentEvent.OnProjectSaving -= FlowEnvironment_OnProjectSaving;
|
||||
flowEnvironmentEvent.OnProjectLoaded -= FlowEnvironment_OnProjectLoaded;
|
||||
flowEnvironmentEvent.OnStartNodeChange -= FlowEnvironment_StartNodeChangeEvent;
|
||||
flowEnvironmentEvent.OnNodeConnectChange -= FlowEnvironment_NodeConnectChangeEvemt;
|
||||
flowEnvironmentEvent.OnNodeCreate -= FlowEnvironment_NodeCreateEvent;
|
||||
flowEnvironmentEvent.OnNodeRemove -= FlowEnvironment_NodeRemoveEvent;
|
||||
flowEnvironmentEvent.OnNodePlace -= EnvDecorator_OnNodePlaceEvent;
|
||||
flowEnvironmentEvent.OnNodeTakeOut -= EnvDecorator_OnNodeTakeOutEvent;
|
||||
flowEnvironmentEvent.OnNodePlace -= FlowEnvironment_OnNodePlaceEvent;
|
||||
flowEnvironmentEvent.OnNodeTakeOut -= FlowEnvironment_OnNodeTakeOutEvent;
|
||||
flowEnvironmentEvent.OnFlowRunComplete -= FlowEnvironment_OnFlowRunCompleteEvent;
|
||||
|
||||
|
||||
@@ -201,7 +201,7 @@ namespace Serein.Workbench.Services
|
||||
/// </summary>
|
||||
/// <param name="eventArgs"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void EnvDecorator_OnProjectSaving(ProjectSavingEventArgs eventArgs)
|
||||
private void FlowEnvironment_OnProjectSaving(ProjectSavingEventArgs eventArgs)
|
||||
{
|
||||
OnProjectSaving?.Invoke(eventArgs);
|
||||
}
|
||||
@@ -289,7 +289,7 @@ namespace Serein.Workbench.Services
|
||||
/// </summary>
|
||||
/// <param name="eventArgs"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void EnvDecorator_OnNodePlaceEvent(NodePlaceEventArgs eventArgs)
|
||||
private void FlowEnvironment_OnNodePlaceEvent(NodePlaceEventArgs eventArgs)
|
||||
{
|
||||
OnNodePlace?.Invoke(eventArgs);
|
||||
}
|
||||
@@ -298,7 +298,7 @@ namespace Serein.Workbench.Services
|
||||
/// 取出一个节点
|
||||
/// </summary>
|
||||
/// <param name="eventArgs"></param>
|
||||
private void EnvDecorator_OnNodeTakeOutEvent(NodeTakeOutEventArgs eventArgs)
|
||||
private void FlowEnvironment_OnNodeTakeOutEvent(NodeTakeOutEventArgs eventArgs)
|
||||
{
|
||||
OnNodeTakeOut?.Invoke(eventArgs);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user