using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Text; namespace Serein.Library { /// /// 节点DLL依赖类,如果一个项目中引入了多个DLL,需要放置在同一个文件夹中 /// public class NodeLibraryInfo { /// /// 文件名 /// public string FileName { get; set; } /// /// 路径 /// public string FilePath { get; set; } /// /// 所属的程序集名称 /// public string AssemblyName{ get; set; } } /// /// /// public class FlowLibrary { public FlowLibrary(string assemblyName, Action actionOfUnloadAssmbly) { this.AssemblyName = assemblyName; this.actionOfUnloadAssmbly = actionOfUnloadAssmbly; } public string AssemblyName { get; } //public string AssemblyVersion { get; } /// /// 加载程序集时创建的方法描述 /// public ConcurrentDictionary MethodDetailss { get; } = new ConcurrentDictionary(); /// /// 管理通过Emit动态构建的委托 /// public ConcurrentDictionary DelegateDetailss { get; } = new ConcurrentDictionary(); /// /// 记录不同的注册时机需要自动创建全局唯一实例的类型信息 /// public ConcurrentDictionary RegisterTypes { get; } = new ConcurrentDictionary(); private readonly Action actionOfUnloadAssmbly; /// /// 卸载当前程序集以及附带的所有信息 /// public void Upload() { actionOfUnloadAssmbly?.Invoke(); } /// /// 通过方法名称获取对应的Emit委托(元数据),用于动态调用节点对应的方法 /// /// 方法名称 /// Emit委托 /// public bool GetDelegateDetails(string methodName, out DelegateDetails dd) { return DelegateDetailss.TryGetValue(methodName, out dd); } /// /// 通过方法名称获取对应的方法描述(元数据),用于创建节点时,节点实例需要的方法描述 /// /// 方法名称 /// 方法描述 /// public bool GetMethodDetails(string methodName, out MethodDetails md) { return MethodDetailss.TryGetValue(methodName, out md); } public NodeLibraryInfo ToInfo() { return new NodeLibraryInfo { } } } }