mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-05-02 13:21:28 +08:00
refactor (env) : 修复了运行环境构建顺序,以及同步上下文在内置ioc中传递的问题
This commit is contained in:
@@ -941,6 +941,11 @@ namespace Serein.Library.Api
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
IFlowControl FlowControl { get; }
|
IFlowControl FlowControl { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 流程依赖类库接口
|
||||||
|
/// </summary>
|
||||||
|
IFlowLibraryService FlowLibraryService { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 流程事件接口
|
/// 流程事件接口
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -1122,6 +1127,13 @@ namespace Serein.Library.Api
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
void ExitRemoteEnv();
|
void ExitRemoteEnv();
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 启动远程服务
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task StartRemoteServerAsync(int port = 7525);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// (用于远程)通知节点属性变更
|
/// (用于远程)通知节点属性变更
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
86
Library/Api/IFlowLibraryService.cs
Normal file
86
Library/Api/IFlowLibraryService.cs
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
using Serein.Library;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace Serein.Library.Api
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 流程依赖程序集管理
|
||||||
|
/// </summary>
|
||||||
|
public interface IFlowLibraryService
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 是否加载了基础依赖
|
||||||
|
/// </summary>
|
||||||
|
bool IsLoadedBaseLibrary { get; }
|
||||||
|
/// <summary>
|
||||||
|
/// 加载基础依赖
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
FlowLibraryInfo LoadBaseLibrary();
|
||||||
|
/// <summary>
|
||||||
|
/// 获取已加载的方法信息
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
List<FlowLibraryInfo> GetAllLibraryInfo();
|
||||||
|
/// <summary>
|
||||||
|
/// 加载指定依赖
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="libraryfilePath"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
FlowLibraryInfo? LoadFlowLibrary(string libraryfilePath);
|
||||||
|
/// <summary>
|
||||||
|
/// 卸载程序集
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assemblyName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool UnloadLibrary(string assemblyName);
|
||||||
|
/// <summary>
|
||||||
|
/// 获取委托
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assemblyName"></param>
|
||||||
|
/// <param name="methodName"></param>
|
||||||
|
/// <param name="dd"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool TryGetDelegateDetails(string assemblyName, string methodName, out DelegateDetails dd);
|
||||||
|
/// <summary>
|
||||||
|
/// 获取方法描述
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assemblyName"></param>
|
||||||
|
/// <param name="methodName"></param>
|
||||||
|
/// <param name="md"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool TryGetMethodDetails(string assemblyName, string methodName, out MethodDetails md);
|
||||||
|
/// <summary>
|
||||||
|
/// 获取反射方法信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assemblyName"></param>
|
||||||
|
/// <param name="methodName"></param>
|
||||||
|
/// <param name="methodInfo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool TryGetMethodInfo(string assemblyName, string methodName, out MethodInfo methodInfo);
|
||||||
|
/// <summary>
|
||||||
|
/// 获取依赖程序集中的类型
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fullName"></param>
|
||||||
|
/// <param name="type"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool TryGetType(string fullName, out Type? type);
|
||||||
|
/// <summary>
|
||||||
|
/// 获取依赖程序集中的类型
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fullName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Type? GetType(string fullName);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取某个节点类型对应的方法描述
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="nodeType"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
List<MethodDetails> GetMdsOnFlowStart(NodeType nodeType);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -51,6 +51,8 @@ namespace Serein.Library
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public UIContextOperation UIContextOperation => throw new NotImplementedException();
|
public UIContextOperation UIContextOperation => throw new NotImplementedException();
|
||||||
|
|
||||||
|
public IFlowLibraryService FlowLibraryService => throw new NotImplementedException();
|
||||||
|
|
||||||
/* public Task<(bool, RemoteMsgUtil)> ConnectRemoteEnv(string addres, int port, string token)
|
/* public Task<(bool, RemoteMsgUtil)> ConnectRemoteEnv(string addres, int port, string token)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
|||||||
@@ -89,7 +89,8 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!--<ProjectReference Include="..\Serein.Library.MyGenerator\Serein.Library.NodeGenerator.csproj " OutputItemType="Analyzer" />-->
|
<!--<ProjectReference Include="..\Serein.Library.MyGenerator\Serein.Library.NodeGenerator.csproj " OutputItemType="Analyzer" />-->
|
||||||
<!-- ReferenceOutputAssembly="false" -->
|
<!-- ReferenceOutputAssembly="false" -->
|
||||||
<ProjectReference Include="..\Serein.Library.MyGenerator\Serein.Library.NodeGenerator.csproj " OutputItemType="Analyzer" />
|
<!--<ProjectReference Include="..\Serein.Library.MyGenerator\Serein.Library.NodeGenerator.csproj " OutputItemType="Analyzer" />-->
|
||||||
|
<ProjectReference Include="..\Serein.Library.NodeGenerator\Serein.Library.NodeGenerator.csproj" OutputItemType="Analyzer"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace Serein.Library.Utils
|
|||||||
public class UIContextOperation
|
public class UIContextOperation
|
||||||
{
|
{
|
||||||
private SynchronizationContext context;
|
private SynchronizationContext context;
|
||||||
private readonly Func<SynchronizationContext> getUiContext = null;
|
public Func<SynchronizationContext> GetUiContext = null;
|
||||||
|
|
||||||
static UIContextOperation()
|
static UIContextOperation()
|
||||||
{
|
{
|
||||||
@@ -55,7 +55,7 @@ namespace Serein.Library.Utils
|
|||||||
[SereinIOCCtor(IsIgnore = true)]
|
[SereinIOCCtor(IsIgnore = true)]
|
||||||
public UIContextOperation(Func<SynchronizationContext> getUiContext)
|
public UIContextOperation(Func<SynchronizationContext> getUiContext)
|
||||||
{
|
{
|
||||||
this.getUiContext = getUiContext;
|
this.GetUiContext = getUiContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -65,9 +65,14 @@ namespace Serein.Library.Utils
|
|||||||
/// <param name="onException">异常发生时的回调</param>
|
/// <param name="onException">异常发生时的回调</param>
|
||||||
public void Invoke(Action uiAction, Action<Exception> onException = null)
|
public void Invoke(Action uiAction, Action<Exception> onException = null)
|
||||||
{
|
{
|
||||||
if(context is null && getUiContext != null)
|
|
||||||
|
if(context is null && GetUiContext != null)
|
||||||
{
|
{
|
||||||
context = getUiContext.Invoke();
|
while (GetUiContext is null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
context = GetUiContext.Invoke();
|
||||||
}
|
}
|
||||||
context?.Post(state =>
|
context?.Post(state =>
|
||||||
{
|
{
|
||||||
@@ -92,9 +97,13 @@ namespace Serein.Library.Utils
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Task InvokeAsync(Action uiAction, Action<Exception> onException = null)
|
public Task InvokeAsync(Action uiAction, Action<Exception> onException = null)
|
||||||
{
|
{
|
||||||
if (context is null && getUiContext != null)
|
if (context is null )
|
||||||
{
|
{
|
||||||
context = getUiContext.Invoke();
|
while (GetUiContext is null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
context = GetUiContext.Invoke();
|
||||||
}
|
}
|
||||||
var tcs = new TaskCompletionSource<bool>();
|
var tcs = new TaskCompletionSource<bool>();
|
||||||
|
|
||||||
|
|||||||
@@ -21,25 +21,23 @@ namespace Serein.NodeFlow.Env
|
|||||||
{
|
{
|
||||||
private readonly IFlowEnvironment flowEnvironment;
|
private readonly IFlowEnvironment flowEnvironment;
|
||||||
private readonly IFlowEnvironmentEvent flowEnvironmentEvent;
|
private readonly IFlowEnvironmentEvent flowEnvironmentEvent;
|
||||||
private readonly FlowLibraryService flowLibraryService;
|
private readonly IFlowLibraryService flowLibraryService;
|
||||||
private readonly FlowOperationService flowOperationService;
|
private readonly FlowOperationService flowOperationService;
|
||||||
private readonly FlowModelService flowModelService;
|
private readonly FlowModelService flowModelService;
|
||||||
private readonly UIContextOperation uiContextOperation;
|
private readonly Lazy<UIContextOperation> uiContextOperation;
|
||||||
|
|
||||||
public FlowControl(IFlowEnvironment flowEnvironment,
|
public FlowControl(IFlowEnvironment flowEnvironment,
|
||||||
IFlowEnvironmentEvent flowEnvironmentEvent,
|
IFlowEnvironmentEvent flowEnvironmentEvent,
|
||||||
FlowLibraryService flowLibraryService,
|
IFlowLibraryService flowLibraryService,
|
||||||
FlowOperationService flowOperationService,
|
FlowOperationService flowOperationService,
|
||||||
FlowModelService flowModelService,
|
FlowModelService flowModelService)
|
||||||
UIContextOperation uiContextOperation)
|
|
||||||
{
|
{
|
||||||
this.flowEnvironment = flowEnvironment;
|
this.flowEnvironment = flowEnvironment;
|
||||||
this.flowEnvironmentEvent = flowEnvironmentEvent;
|
this.flowEnvironmentEvent = flowEnvironmentEvent;
|
||||||
this.flowLibraryService = flowLibraryService;
|
this.flowLibraryService = flowLibraryService;
|
||||||
this.flowOperationService = flowOperationService;
|
this.flowOperationService = flowOperationService;
|
||||||
this.flowModelService = flowModelService;
|
this.flowModelService = flowModelService;
|
||||||
this.uiContextOperation = uiContextOperation;
|
uiContextOperation = new Lazy<UIContextOperation>(() => flowEnvironment.IOC.Get<UIContextOperation>());
|
||||||
|
|
||||||
contexts = new ObjectPool<IFlowContext>(() => new FlowContext(flowEnvironment), context => context.Reset());
|
contexts = new ObjectPool<IFlowContext>(() => new FlowContext(flowEnvironment), context => context.Reset());
|
||||||
flowTaskOptions = new FlowWorkOptions
|
flowTaskOptions = new FlowWorkOptions
|
||||||
{
|
{
|
||||||
@@ -340,7 +338,7 @@ namespace Serein.NodeFlow.Env
|
|||||||
{
|
{
|
||||||
flowWorkManagement.Exit();
|
flowWorkManagement.Exit();
|
||||||
}
|
}
|
||||||
uiContextOperation?.Invoke(() => flowEnvironmentEvent.OnFlowRunComplete(new FlowEventArgs()));
|
uiContextOperation.Value.Invoke(() => flowEnvironmentEvent.OnFlowRunComplete(new FlowEventArgs()));
|
||||||
IOC.Reset();
|
IOC.Reset();
|
||||||
GC.Collect();
|
GC.Collect();
|
||||||
return Task.FromResult(true);
|
return Task.FromResult(true);
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace Serein.NodeFlow.Env
|
|||||||
{
|
{
|
||||||
public FlowEdit(IFlowEnvironment flowEnvironment,
|
public FlowEdit(IFlowEnvironment flowEnvironment,
|
||||||
IFlowEnvironmentEvent flowEnvironmentEvent,
|
IFlowEnvironmentEvent flowEnvironmentEvent,
|
||||||
FlowLibraryService flowLibraryManagement,
|
IFlowLibraryService flowLibraryManagement,
|
||||||
FlowOperationService flowOperationService,
|
FlowOperationService flowOperationService,
|
||||||
FlowModelService flowModelService,
|
FlowModelService flowModelService,
|
||||||
UIContextOperation UIContextOperation,
|
UIContextOperation UIContextOperation,
|
||||||
@@ -45,7 +45,7 @@ namespace Serein.NodeFlow.Env
|
|||||||
|
|
||||||
private readonly IFlowEnvironment flowEnvironment;
|
private readonly IFlowEnvironment flowEnvironment;
|
||||||
private readonly IFlowEnvironmentEvent flowEnvironmentEvent;
|
private readonly IFlowEnvironmentEvent flowEnvironmentEvent;
|
||||||
private readonly FlowLibraryService flowLibraryManagement;
|
private readonly IFlowLibraryService flowLibraryManagement;
|
||||||
private readonly FlowOperationService flowOperationService;
|
private readonly FlowOperationService flowOperationService;
|
||||||
private readonly FlowModelService flowModelService;
|
private readonly FlowModelService flowModelService;
|
||||||
|
|
||||||
|
|||||||
@@ -49,11 +49,46 @@ namespace Serein.NodeFlow.Env
|
|||||||
public FlowEnvironment()
|
public FlowEnvironment()
|
||||||
{
|
{
|
||||||
ISereinIOC ioc = new SereinIOC();
|
ISereinIOC ioc = new SereinIOC();
|
||||||
ioc.Register<ISereinIOC>(()=> ioc) // IOC容器接口
|
ioc.Register<ISereinIOC>(() => ioc) // IOC容器接口
|
||||||
.Register<IFlowEnvironment>(() => this) // 流程环境接口
|
.Register<IFlowEnvironment>(() => this) // 流程环境接口
|
||||||
.Register<IFlowEnvironmentEvent, FlowEnvironmentEvent>() // 流程环境事件接口
|
.Register<IFlowEnvironmentEvent, FlowEnvironmentEvent>() // 流程环境事件接口
|
||||||
.Register<IFlowEdit, FlowEdit>() // 流程编辑接口
|
.Register<IFlowEdit, FlowEdit>() // 流程编辑接口
|
||||||
.Register<IFlowControl, FlowControl>() // 流程控制接口
|
.Register<IFlowControl, FlowControl>() // 流程控制接口
|
||||||
|
.Register<IFlowLibraryService, FlowLibraryService>() // 流程库服务
|
||||||
|
.Register<LocalFlowEnvironment>() // 本地环境
|
||||||
|
.Register<FlowModelService>() // 节点/画布模型服务
|
||||||
|
.Register<FlowCoreGenerateService>() // 代码生成
|
||||||
|
.Register<FlowOperationService>() // 流程操作
|
||||||
|
.Register<NodeMVVMService>() // 节点MVVM服务
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
// 设置JSON解析器
|
||||||
|
if (JsonHelper.Provider is null)
|
||||||
|
{
|
||||||
|
JsonHelper.UseJsonProvider(new NewtonsoftJsonProvider());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 默认使用本地环境
|
||||||
|
localFlowEnvironment = ioc.Get<LocalFlowEnvironment>();
|
||||||
|
currentFlowEnvironmentEvent = ioc.Get<IFlowEnvironmentEvent>();
|
||||||
|
currentFlowEnvironment = localFlowEnvironment;
|
||||||
|
SereinEnv.SetEnv(localFlowEnvironment);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 提供上下文操作进行调用
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="operation"></param>
|
||||||
|
public FlowEnvironment(UIContextOperation operation)
|
||||||
|
{
|
||||||
|
ISereinIOC ioc = new SereinIOC();
|
||||||
|
ioc.Register<ISereinIOC>(() => ioc) // IOC容器接口
|
||||||
|
.Register<IFlowEnvironment>(() => this) // 流程环境接口
|
||||||
|
.Register<IFlowEnvironmentEvent, FlowEnvironmentEvent>() // 流程环境事件接口
|
||||||
|
.Register<IFlowLibraryService, FlowLibraryService>()
|
||||||
|
.Register<UIContextOperation>(() => operation) // 流程环境接口
|
||||||
|
.Register<IFlowEdit, FlowEdit>() // 流程编辑接口
|
||||||
|
.Register<IFlowControl, FlowControl>() // 流程控制接口
|
||||||
.Register<LocalFlowEnvironment>() // 本地环境
|
.Register<LocalFlowEnvironment>() // 本地环境
|
||||||
.Register<FlowModelService>() // 节点/画布模型服务
|
.Register<FlowModelService>() // 节点/画布模型服务
|
||||||
.Register<FlowLibraryService>() // 流程库服务
|
.Register<FlowLibraryService>() // 流程库服务
|
||||||
@@ -69,54 +104,17 @@ namespace Serein.NodeFlow.Env
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 默认使用本地环境
|
// 默认使用本地环境
|
||||||
currentFlowEnvironment = ioc.Get<LocalFlowEnvironment>();
|
localFlowEnvironment = ioc.Get<LocalFlowEnvironment>();
|
||||||
currentFlowEnvironmentEvent = ioc.Get<IFlowEnvironmentEvent>();
|
currentFlowEnvironmentEvent = ioc.Get<IFlowEnvironmentEvent>();
|
||||||
SereinEnv.SetEnv(currentFlowEnvironment);
|
currentFlowEnvironment = localFlowEnvironment;
|
||||||
|
SereinEnv.SetEnv(localFlowEnvironment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 提供上下文操作进行调用
|
/// 管理当前环境
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="operation"></param>
|
|
||||||
public FlowEnvironment(UIContextOperation operation)
|
|
||||||
{
|
|
||||||
ISereinIOC ioc = new SereinIOC();
|
|
||||||
ioc.Register<ISereinIOC>(()=> ioc) // IOC容器接口
|
|
||||||
.Register<UIContextOperation>(() => operation) // 流程环境接口
|
|
||||||
.Register<IFlowEnvironment>(() => this) // 流程环境接口
|
|
||||||
.Register<IFlowEnvironmentEvent, FlowEnvironmentEvent>() // 流程环境事件接口
|
|
||||||
.Register<IFlowEdit, FlowEdit>() // 流程编辑接口
|
|
||||||
.Register<IFlowControl, FlowControl>() // 流程控制接口
|
|
||||||
.Register<LocalFlowEnvironment>() // 本地环境
|
|
||||||
.Register<FlowModelService>() // 节点/画布模型服务
|
|
||||||
.Register<FlowLibraryService>() // 流程库服务
|
|
||||||
.Register<FlowCoreGenerateService>() // 代码生成
|
|
||||||
.Register<FlowOperationService>() // 流程操作
|
|
||||||
.Register<NodeMVVMService>() // 节点MVVM服务
|
|
||||||
.Build();
|
|
||||||
|
|
||||||
// 设置JSON解析器
|
private LocalFlowEnvironment localFlowEnvironment;
|
||||||
if (JsonHelper.Provider is null)
|
|
||||||
{
|
|
||||||
JsonHelper.UseJsonProvider(new NewtonsoftJsonProvider());
|
|
||||||
}
|
|
||||||
|
|
||||||
// 默认使用本地环境
|
|
||||||
currentFlowEnvironment = ioc.Get<LocalFlowEnvironment>();
|
|
||||||
currentFlowEnvironmentEvent = ioc.Get<IFlowEnvironmentEvent>();
|
|
||||||
SereinEnv.SetEnv(currentFlowEnvironment);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
/// <summary>
|
|
||||||
/// 本地环境事件
|
|
||||||
/// </summary>
|
|
||||||
private readonly IFlowEnvironmentEvent flowEnvironmentEvent;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 远程环境事件
|
|
||||||
/// </summary>
|
|
||||||
private IFlowEnvironmentEvent remoteFlowEnvironmentEvent;
|
|
||||||
*/
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 管理当前环境
|
/// 管理当前环境
|
||||||
@@ -129,8 +127,6 @@ namespace Serein.NodeFlow.Env
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private IFlowEnvironmentEvent currentFlowEnvironmentEvent;
|
private IFlowEnvironmentEvent currentFlowEnvironmentEvent;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private int _loadingProjectFlag = 0; // 使用原子自增代替锁
|
private int _loadingProjectFlag = 0; // 使用原子自增代替锁
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 传入false时,将停止数据通知。传入true时,
|
/// 传入false时,将停止数据通知。传入true时,
|
||||||
@@ -160,6 +156,9 @@ namespace Serein.NodeFlow.Env
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public IFlowControl FlowControl => currentFlowEnvironment.FlowControl;
|
public IFlowControl FlowControl => currentFlowEnvironment.FlowControl;
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public IFlowLibraryService FlowLibraryService => currentFlowEnvironment.FlowLibraryService;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public ISereinIOC IOC => currentFlowEnvironment.IOC;
|
public ISereinIOC IOC => currentFlowEnvironment.IOC;
|
||||||
|
|
||||||
@@ -259,12 +258,6 @@ namespace Serein.NodeFlow.Env
|
|||||||
SetProjectLoadingFlag(true);
|
SetProjectLoadingFlag(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* /// <inheritdoc/>
|
|
||||||
public void MonitorObjectNotification(string nodeGuid, object monitorData, MonitorObjectEventArgs.ObjSourceType sourceType)
|
|
||||||
{
|
|
||||||
currentFlowEnvironment.FlowControl.MonitorObjectNotification(nodeGuid, monitorData, sourceType);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public bool TryUnloadLibrary(string assemblyName)
|
public bool TryUnloadLibrary(string assemblyName)
|
||||||
{
|
{
|
||||||
@@ -312,43 +305,14 @@ namespace Serein.NodeFlow.Env
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
/*
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public async Task<bool> StartFlowAsync(string[] canvasGuids)
|
public Task StartRemoteServerAsync(int port = 7525)
|
||||||
{
|
{
|
||||||
return await currentFlowEnvironment.FlowControl.StartFlowAsync(canvasGuids);
|
|
||||||
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public async Task<TResult> StartFlowAsync<TResult>(string startNodeGuid)
|
|
||||||
{
|
|
||||||
return await currentFlowEnvironment.FlowControl.StartFlowAsync<TResult>(startNodeGuid);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/* /// <inheritdoc/>
|
|
||||||
public async Task StartRemoteServerAsync(int port = 7525)
|
|
||||||
{
|
|
||||||
await currentFlowEnvironment.StartRemoteServerAsync(port);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public void StopRemoteServer()
|
|
||||||
{
|
|
||||||
currentFlowEnvironment.StopRemoteServer();
|
|
||||||
}*/
|
|
||||||
/*
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public void TerminateFlipflopNode(string nodeGuid)
|
|
||||||
{
|
|
||||||
currentFlowEnvironment.FlowControl.TerminateFlipflopNode(nodeGuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public void TriggerInterrupt(string nodeGuid, string expression, InterruptTriggerEventArgs.InterruptTriggerType type)
|
|
||||||
{
|
|
||||||
currentFlowEnvironment.FlowControl.TriggerInterrupt(nodeGuid, expression, type);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void SetUIContextOperation(UIContextOperation uiContextOperation)
|
public void SetUIContextOperation(UIContextOperation uiContextOperation)
|
||||||
@@ -356,12 +320,6 @@ namespace Serein.NodeFlow.Env
|
|||||||
|
|
||||||
currentFlowEnvironment.SetUIContextOperation(uiContextOperation);
|
currentFlowEnvironment.SetUIContextOperation(uiContextOperation);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public void UseExternalIOC(ISereinIOC ioc)
|
|
||||||
{
|
|
||||||
currentFlowEnvironment.FlowControl.UseExternalIOC(ioc);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public bool TryGetNodeModel(string nodeGuid, out IFlowNode nodeModel)
|
public bool TryGetNodeModel(string nodeGuid, out IFlowNode nodeModel)
|
||||||
@@ -409,6 +367,7 @@ namespace Serein.NodeFlow.Env
|
|||||||
currentFlowEnvironment.LoadAllNativeLibraryOfRuning(path,isRecurrence);
|
currentFlowEnvironment.LoadAllNativeLibraryOfRuning(path,isRecurrence);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,14 +18,14 @@ namespace Serein.NodeFlow.Services
|
|||||||
public class FlowCoreGenerateService
|
public class FlowCoreGenerateService
|
||||||
{
|
{
|
||||||
private readonly FlowModelService flowModelService;
|
private readonly FlowModelService flowModelService;
|
||||||
private readonly FlowLibraryService flowLibraryService;
|
private readonly IFlowLibraryService flowLibraryService;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 流程代码生成服务
|
/// 流程代码生成服务
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="flowModelService"></param>
|
/// <param name="flowModelService"></param>
|
||||||
/// <param name="flowLibraryService"></param>
|
/// <param name="flowLibraryService"></param>
|
||||||
public FlowCoreGenerateService(FlowModelService flowModelService ,FlowLibraryService flowLibraryService )
|
public FlowCoreGenerateService(FlowModelService flowModelService ,IFlowLibraryService flowLibraryService )
|
||||||
{
|
{
|
||||||
this.flowModelService = flowModelService;
|
this.flowModelService = flowModelService;
|
||||||
this.flowLibraryService = flowLibraryService;
|
this.flowLibraryService = flowLibraryService;
|
||||||
|
|||||||
@@ -9,10 +9,11 @@ using System.Xml.Linq;
|
|||||||
|
|
||||||
namespace Serein.NodeFlow.Services
|
namespace Serein.NodeFlow.Services
|
||||||
{
|
{
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 管理加载在运行环境中的外部程序集
|
/// 管理加载在运行环境中的外部程序集
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class FlowLibraryService
|
public class FlowLibraryService : IFlowLibraryService
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否加载过基础依赖
|
/// 是否加载过基础依赖
|
||||||
@@ -49,7 +50,7 @@ namespace Serein.NodeFlow.Services
|
|||||||
private bool CheckBaseLibrary(string libraryfilePath, out string baseLibraryPath)
|
private bool CheckBaseLibrary(string libraryfilePath, out string baseLibraryPath)
|
||||||
{
|
{
|
||||||
var dir = Path.GetDirectoryName(libraryfilePath); // 获取目录路径
|
var dir = Path.GetDirectoryName(libraryfilePath); // 获取目录路径
|
||||||
ArgumentNullException.ThrowIfNullOrWhiteSpace(dir);
|
ArgumentException.ThrowIfNullOrWhiteSpace(dir);
|
||||||
var sereinFlowBaseLibraryPath = Path.Combine(dir, SereinBaseLibrary);
|
var sereinFlowBaseLibraryPath = Path.Combine(dir, SereinBaseLibrary);
|
||||||
if (!Path.Exists(sereinFlowBaseLibraryPath))
|
if (!Path.Exists(sereinFlowBaseLibraryPath))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,19 +7,19 @@ using System.Diagnostics.CodeAnalysis;
|
|||||||
namespace Serein.NodeFlow.Services
|
namespace Serein.NodeFlow.Services
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 流程模型服务
|
/// 流程画布/节点数据实体服务
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class FlowModelService
|
public class FlowModelService
|
||||||
{
|
{
|
||||||
private readonly IFlowEnvironment environment;
|
private readonly IFlowEnvironment environment;
|
||||||
private readonly FlowLibraryService flowLibraryService;
|
private readonly IFlowLibraryService flowLibraryService;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 流程模型服务构造函数
|
/// 流程模型服务构造函数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="environment"></param>
|
/// <param name="environment"></param>
|
||||||
/// <param name="flowLibraryService"></param>
|
/// <param name="flowLibraryService"></param>
|
||||||
public FlowModelService(IFlowEnvironment environment, FlowLibraryService flowLibraryService)
|
public FlowModelService(IFlowEnvironment environment, IFlowLibraryService flowLibraryService)
|
||||||
{
|
{
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
this.flowLibraryService = flowLibraryService;
|
this.flowLibraryService = flowLibraryService;
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Serein.NodeFlow.Services
|
namespace Serein.NodeFlow.Services
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 流程操作
|
||||||
|
/// </summary>
|
||||||
internal class FlowOperationService
|
internal class FlowOperationService
|
||||||
{
|
{
|
||||||
private readonly ISereinIOC sereinIOC;
|
private readonly ISereinIOC sereinIOC;
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ namespace Serein.Workbench
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
var projectService = App.GetService<FlowProjectService>();
|
var projectService = App.GetService<FlowProjectService>();
|
||||||
|
|
||||||
if (e.Args.Length == 1)
|
if (e.Args.Length == 1)
|
||||||
{
|
{
|
||||||
string filePath = e.Args[0];
|
string filePath = e.Args[0];
|
||||||
|
|||||||
@@ -54,28 +54,48 @@ namespace Serein.Workbench
|
|||||||
/// <param name="collection"></param>
|
/// <param name="collection"></param>
|
||||||
public static void AddFlowServices(this IServiceCollection collection)
|
public static void AddFlowServices(this IServiceCollection collection)
|
||||||
{
|
{
|
||||||
#region 创建实例
|
|
||||||
JsonHelper.UseJsonProvider(new NewtonsoftJsonProvider());
|
|
||||||
Func<SynchronizationContext>? getSyncContext = null;
|
Func<SynchronizationContext>? getSyncContext = null;
|
||||||
|
UIContextOperation? uIContextOperation = new(getSyncContext); // 封装一个调用UI线程的工具类
|
||||||
|
IFlowEnvironment flowEnvironment = new FlowEnvironment(uIContextOperation);
|
||||||
Dispatcher.CurrentDispatcher.Invoke(() =>
|
Dispatcher.CurrentDispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
var uiContext = SynchronizationContext.Current; // 在UI线程上获取UI线程上下文信息
|
if (SynchronizationContext.Current is { } uiContext)
|
||||||
if (uiContext is not null)
|
|
||||||
{
|
{
|
||||||
|
// 在UI线程上获取UI线程上下文信息
|
||||||
getSyncContext = () => uiContext;
|
getSyncContext = () => uiContext;
|
||||||
|
|
||||||
|
flowEnvironment.UIContextOperation.GetUiContext = () => uiContext;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
UIContextOperation? uIContextOperation = new (getSyncContext); // 封装一个调用UI线程的工具类
|
|
||||||
IFlowEnvironment flowEnvironment = new FlowEnvironment();
|
|
||||||
flowEnvironment.SetUIContextOperation(uIContextOperation);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
collection.AddSingleton<UIContextOperation>(uIContextOperation); // 注册UI线程操作上下文
|
collection.AddSingleton<UIContextOperation>(uIContextOperation); // 注册UI线程操作上下文
|
||||||
collection.AddSingleton<IFlowEnvironment>(flowEnvironment); // 注册运行环境
|
collection.AddSingleton<IFlowEnvironment>(flowEnvironment); // 注册运行环境
|
||||||
collection.AddSingleton<IFlowEnvironmentEvent>(flowEnvironment.Event); // 注册运行环境事件
|
collection.AddSingleton<IFlowEnvironmentEvent>(flowEnvironment.Event); // 注册运行环境事件
|
||||||
|
collection.AddSingleton<IFlowEEForwardingService, FlowEEForwardingService>(); // 注册工作台环境事件
|
||||||
|
|
||||||
#endregion
|
//#region 创建实例
|
||||||
|
|
||||||
|
//Func<SynchronizationContext>? getSyncContext = null;
|
||||||
|
//Dispatcher.CurrentDispatcher.Invoke(() =>
|
||||||
|
//{
|
||||||
|
// var uiContext = SynchronizationContext.Current; // 在UI线程上获取UI线程上下文信息
|
||||||
|
// if (uiContext is not null)
|
||||||
|
// {
|
||||||
|
// getSyncContext = () => uiContext;
|
||||||
|
// }
|
||||||
|
//});
|
||||||
|
//UIContextOperation? uIContextOperation = new (getSyncContext); // 封装一个调用UI线程的工具类
|
||||||
|
//IFlowEnvironment flowEnvironment = new FlowEnvironment();
|
||||||
|
//flowEnvironment.SetUIContextOperation(uIContextOperation);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//collection.AddSingleton<UIContextOperation>(uIContextOperation); // 注册UI线程操作上下文
|
||||||
|
//collection.AddSingleton<IFlowEnvironment>(flowEnvironment); // 注册运行环境
|
||||||
|
//collection.AddSingleton<IFlowEnvironmentEvent>(flowEnvironment.Event); // 注册运行环境事件
|
||||||
|
|
||||||
|
//#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user