mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-04-04 07:16:35 +08:00
改写了流程依赖管理,封装为一个工具类,将来计划实现动态增加卸载/更新类库的功能
This commit is contained in:
@@ -676,8 +676,8 @@ namespace Serein.Library.Api
|
||||
/// <summary>
|
||||
/// 移除DLL
|
||||
/// </summary>
|
||||
/// <param name="assemblyName">程序集的名称</param>
|
||||
bool RemoteDll(string assemblyName);
|
||||
/// <param name="assemblyFullName">程序集的名称</param>
|
||||
bool RemoteDll(string assemblyFullName);
|
||||
|
||||
/// <summary>
|
||||
/// 清理加载的DLL(待更改)
|
||||
@@ -860,7 +860,7 @@ namespace Serein.Library.Api
|
||||
/// <param name="methodName">方法描述</param>
|
||||
/// <param name="mdInfo">方法信息</param>
|
||||
/// <returns></returns>
|
||||
bool TryGetMethodDetailsInfo(string methodName, out MethodDetailsInfo mdInfo);
|
||||
bool TryGetMethodDetailsInfo(string libraryName, string methodName, out MethodDetailsInfo mdInfo);
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定方法的Emit委托
|
||||
@@ -868,7 +868,7 @@ namespace Serein.Library.Api
|
||||
/// <param name="methodName"></param>
|
||||
/// <param name="del"></param>
|
||||
/// <returns></returns>
|
||||
bool TryGetDelegateDetails(string methodName, out DelegateDetails del);
|
||||
bool TryGetDelegateDetails(string libraryName, string methodName, out DelegateDetails del);
|
||||
|
||||
|
||||
#region 远程相关
|
||||
|
||||
@@ -1,108 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace Serein.Library
|
||||
{
|
||||
/// <summary>
|
||||
/// 节点DLL依赖类,如果一个项目中引入了多个DLL,需要放置在同一个文件夹中
|
||||
/// </summary>
|
||||
public class NodeLibraryInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件名
|
||||
/// </summary>
|
||||
public string FileName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 路径
|
||||
/// </summary>
|
||||
public string FilePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所属的程序集名称
|
||||
/// </summary>
|
||||
public string AssemblyName{ get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class FlowLibrary
|
||||
{
|
||||
public FlowLibrary(string assemblyName,
|
||||
Action actionOfUnloadAssmbly)
|
||||
{
|
||||
this.AssemblyName = assemblyName;
|
||||
this.actionOfUnloadAssmbly = actionOfUnloadAssmbly;
|
||||
}
|
||||
|
||||
public string AssemblyName { get; }
|
||||
|
||||
//public string AssemblyVersion { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 加载程序集时创建的方法描述
|
||||
/// </summary>
|
||||
public ConcurrentDictionary<string, MethodDetails> MethodDetailss { get; } = new ConcurrentDictionary<string, MethodDetails>();
|
||||
|
||||
/// <summary>
|
||||
/// 管理通过Emit动态构建的委托
|
||||
/// </summary>
|
||||
public ConcurrentDictionary<string, DelegateDetails> DelegateDetailss { get; } = new ConcurrentDictionary<string, DelegateDetails>();
|
||||
|
||||
/// <summary>
|
||||
/// 记录不同的注册时机需要自动创建全局唯一实例的类型信息
|
||||
/// </summary>
|
||||
public ConcurrentDictionary<RegisterSequence, Type[]> RegisterTypes { get; } = new ConcurrentDictionary<RegisterSequence, Type[]>();
|
||||
|
||||
|
||||
private readonly Action actionOfUnloadAssmbly;
|
||||
|
||||
/// <summary>
|
||||
/// 卸载当前程序集以及附带的所有信息
|
||||
/// </summary>
|
||||
public void Upload()
|
||||
{
|
||||
actionOfUnloadAssmbly?.Invoke();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 通过方法名称获取对应的Emit委托(元数据),用于动态调用节点对应的方法
|
||||
/// </summary>
|
||||
/// <param name="methodName">方法名称</param>
|
||||
/// <param name="dd">Emit委托</param>
|
||||
/// <returns></returns>
|
||||
public bool GetDelegateDetails(string methodName, out DelegateDetails dd)
|
||||
{
|
||||
return DelegateDetailss.TryGetValue(methodName, out dd);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过方法名称获取对应的方法描述(元数据),用于创建节点时,节点实例需要的方法描述
|
||||
/// </summary>
|
||||
/// <param name="methodName">方法名称</param>
|
||||
/// <param name="md">方法描述</param>
|
||||
/// <returns></returns>
|
||||
public bool GetMethodDetails(string methodName, out MethodDetails md)
|
||||
{
|
||||
return MethodDetailss.TryGetValue(methodName, out md);
|
||||
}
|
||||
|
||||
public NodeLibraryInfo ToInfo()
|
||||
{
|
||||
return new NodeLibraryInfo
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
using Serein.Library.Utils;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace Serein.Library
|
||||
@@ -21,6 +22,13 @@ namespace Serein.Library
|
||||
[PropertyInfo(IsProtection = true)]
|
||||
private NodeModelBase _nodeModel;
|
||||
|
||||
/// <summary>
|
||||
/// 对应的程序集
|
||||
/// </summary>
|
||||
[PropertyInfo]
|
||||
private string _assemblyName;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 是否保护参数(目前仅视觉效果参数,不影响运行实现,后续将设置作用在运行逻辑中)
|
||||
/// </summary>
|
||||
@@ -188,6 +196,7 @@ namespace Serein.Library
|
||||
{
|
||||
throw new ArgumentException("无效的节点类型");
|
||||
}
|
||||
AssemblyName = Info.AssemblyName;
|
||||
MethodName = Info.MethodName;
|
||||
MethodAnotherName = Info.MethodAnotherName;
|
||||
MethodDynamicType = nodeType;
|
||||
@@ -204,6 +213,7 @@ namespace Serein.Library
|
||||
{
|
||||
return new MethodDetailsInfo
|
||||
{
|
||||
AssemblyName = this.AssemblyName,
|
||||
MethodName = this.MethodName,
|
||||
MethodAnotherName = this.MethodAnotherName,
|
||||
NodeType = this.MethodDynamicType.ToString(),
|
||||
@@ -222,6 +232,7 @@ namespace Serein.Library
|
||||
// this => 是元数据
|
||||
var md = new MethodDetails( nodeModel) // 创建新节点时拷贝实例
|
||||
{
|
||||
AssemblyName = this.AssemblyName,
|
||||
ActingInstance = this.ActingInstance,
|
||||
ActingInstanceType = this.ActingInstanceType,
|
||||
MethodDynamicType = this.MethodDynamicType,
|
||||
@@ -231,8 +242,9 @@ namespace Serein.Library
|
||||
MethodLockName = this.MethodLockName,
|
||||
IsProtectionParameter = this.IsProtectionParameter,
|
||||
ParamsArgIndex = this.ParamsArgIndex,
|
||||
ParameterDetailss = this.ParameterDetailss?.Select(p => p?.CloneOfModel(nodeModel)).ToArray(), // 拷贝属于节点方法的新入参描述
|
||||
};
|
||||
md.ParameterDetailss = this.ParameterDetailss?.Select(p => p?.CloneOfModel(nodeModel)).ToArray(); // 拷贝属于节点方法的新入参描述
|
||||
|
||||
return md;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ namespace Serein.Library
|
||||
return new NodeInfo
|
||||
{
|
||||
Guid = Guid,
|
||||
AssemblyName = MethodDetails.AssemblyName,
|
||||
MethodName = MethodDetails?.MethodName,
|
||||
Label = MethodDetails?.MethodAnotherName,
|
||||
Type = this.GetType().ToString(),
|
||||
@@ -316,7 +317,7 @@ namespace Serein.Library
|
||||
{
|
||||
throw new Exception($"节点{this.Guid}不存在方法信息,请检查是否需要重写节点的ExecutingAsync");
|
||||
}
|
||||
if (!context.Env.TryGetDelegateDetails(md.MethodName, out var dd))
|
||||
if (!context.Env.TryGetDelegateDetails(md.AssemblyName, md.MethodName, out var dd))
|
||||
{
|
||||
throw new Exception($"节点{this.Guid}不存在对应委托");
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace Serein.Library
|
||||
/// 依赖的DLL
|
||||
/// </summary>
|
||||
|
||||
public Library[] Librarys { get; set; }
|
||||
public NodeLibraryInfo[] Librarys { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 起始节点GUID
|
||||
@@ -132,38 +132,63 @@ namespace Serein.Library
|
||||
/// <summary>
|
||||
/// 项目依赖的程序集,项目文件相关
|
||||
/// </summary>
|
||||
public class Library
|
||||
/// <summary>
|
||||
public class NodeLibraryInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件名称
|
||||
/// 文件名
|
||||
/// </summary>
|
||||
|
||||
public string FileName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件路径
|
||||
/// 路径
|
||||
/// </summary>
|
||||
public string FilePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 程序集名称
|
||||
/// 所属的程序集名称
|
||||
/// </summary>
|
||||
public string AssemblyName { get; set; }
|
||||
}
|
||||
|
||||
#region 暂时注释
|
||||
/*public class LibraryInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件名称
|
||||
/// </summary>
|
||||
|
||||
public string FileName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件路径
|
||||
/// </summary>
|
||||
public string FilePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 程序集名称
|
||||
/// </summary>
|
||||
public string AssemblyName { get; set; }
|
||||
}*/
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 节点信息,项目文件相关
|
||||
/// </summary>
|
||||
public class NodeInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// GUID
|
||||
/// 节点的GUID
|
||||
/// </summary>
|
||||
|
||||
public string Guid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// 节点方法所属的程序集名称
|
||||
/// </summary>
|
||||
public string AssemblyName { get;set; }
|
||||
|
||||
/// <summary>
|
||||
/// 节点对应的名称
|
||||
/// </summary>
|
||||
|
||||
public string MethodName { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user