refactor (env) : 修复了运行环境构建顺序,以及同步上下文在内置ioc中传递的问题

This commit is contained in:
fengjiayi
2026-01-27 17:24:19 +08:00
parent f335439732
commit dddc3b3b53
14 changed files with 215 additions and 123 deletions

View File

@@ -941,6 +941,11 @@ namespace Serein.Library.Api
/// </summary>
IFlowControl FlowControl { get; }
/// <summary>
/// 流程依赖类库接口
/// </summary>
IFlowLibraryService FlowLibraryService { get; }
/// <summary>
/// 流程事件接口
/// </summary>
@@ -1122,6 +1127,13 @@ namespace Serein.Library.Api
/// </summary>
void ExitRemoteEnv();
*/
/// <summary>
/// 启动远程服务
/// </summary>
/// <returns></returns>
Task StartRemoteServerAsync(int port = 7525);
/// <summary>
/// (用于远程)通知节点属性变更
/// </summary>

View 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);
}
}

View File

@@ -51,6 +51,8 @@ namespace Serein.Library
/// <inheritdoc/>
public UIContextOperation UIContextOperation => throw new NotImplementedException();
public IFlowLibraryService FlowLibraryService => throw new NotImplementedException();
/* public Task<(bool, RemoteMsgUtil)> ConnectRemoteEnv(string addres, int port, string token)
{
throw new NotImplementedException();

View File

@@ -89,7 +89,8 @@
<ItemGroup>
<!--<ProjectReference Include="..\Serein.Library.MyGenerator\Serein.Library.NodeGenerator.csproj " OutputItemType="Analyzer" />-->
<!-- 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>
</Project>

View File

@@ -17,7 +17,7 @@ namespace Serein.Library.Utils
public class UIContextOperation
{
private SynchronizationContext context;
private readonly Func<SynchronizationContext> getUiContext = null;
public Func<SynchronizationContext> GetUiContext = null;
static UIContextOperation()
{
@@ -55,7 +55,7 @@ namespace Serein.Library.Utils
[SereinIOCCtor(IsIgnore = true)]
public UIContextOperation(Func<SynchronizationContext> getUiContext)
{
this.getUiContext = getUiContext;
this.GetUiContext = getUiContext;
}
/// <summary>
@@ -65,9 +65,14 @@ namespace Serein.Library.Utils
/// <param name="onException">异常发生时的回调</param>
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 =>
{
@@ -92,9 +97,13 @@ namespace Serein.Library.Utils
/// <returns></returns>
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>();