mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-03 00:00:49 +08:00
NodeMVVMManagement不再是静态类,而是运行环境内部的成员。
This commit is contained in:
@@ -705,7 +705,10 @@ namespace Serein.Library.Api
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
UIContextOperation UIContextOperation { get; }
|
UIContextOperation UIContextOperation { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 节点视图模型管理类
|
||||||
|
/// </summary>
|
||||||
|
NodeMVVMManagement NodeMVVMManagement { get; }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 基本接口
|
#region 基本接口
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ namespace Serein.Library
|
|||||||
public IFlowEnvironment CurrentEnv => this;
|
public IFlowEnvironment CurrentEnv => this;
|
||||||
|
|
||||||
public UIContextOperation UIContextOperation { get; set; }
|
public UIContextOperation UIContextOperation { get; set; }
|
||||||
|
public NodeMVVMManagement NodeMVVMManagement { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置在UI线程操作的线程上下文
|
/// 设置在UI线程操作的线程上下文
|
||||||
|
|||||||
@@ -7,32 +7,34 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Serein.NodeFlow
|
namespace Serein.Library
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 节点类型
|
/// 节点类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class NodeMVVM
|
public class NodeMVVM
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 节点类型
|
/// 节点类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public required NodeControlType NodeType { get; set; }
|
public NodeControlType NodeType { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 节点Model类型
|
/// 节点Model类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public required Type ModelType { get; set; }
|
public Type ModelType { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 节点视图控件类型
|
/// 节点视图控件类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Type? ControlType { get; set; }
|
public Type ControlType { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 节点视图VM类型
|
/// 节点视图VM类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Type? ViewModelType { get; set; }
|
public Type ViewModelType { get; set; }
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
@@ -43,19 +45,19 @@ namespace Serein.NodeFlow
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 节点 数据、视图、VM 管理
|
/// 节点 数据、视图、VM 管理
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class NodeMVVMManagement
|
public class NodeMVVMManagement
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 节点对应的控件类型
|
/// 节点对应的控件类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static ConcurrentDictionary<NodeControlType, NodeMVVM> FlowNodeTypes { get; } = [];
|
private ConcurrentDictionary<NodeControlType, NodeMVVM> FlowNodeTypes { get; } = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 注册 Model 类型
|
/// 注册 Model 类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
/// <param name="modelType"></param>
|
/// <param name="modelType"></param>
|
||||||
public static bool RegisterModel(NodeControlType type, Type modelType)
|
public bool RegisterModel(NodeControlType type, Type modelType)
|
||||||
{
|
{
|
||||||
if(FlowNodeTypes.TryGetValue(type,out var nodeMVVM))
|
if(FlowNodeTypes.TryGetValue(type,out var nodeMVVM))
|
||||||
{
|
{
|
||||||
@@ -76,7 +78,7 @@ namespace Serein.NodeFlow
|
|||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
/// <param name="controlType"></param>
|
/// <param name="controlType"></param>
|
||||||
/// <param name="viewModelType"></param>
|
/// <param name="viewModelType"></param>
|
||||||
public static bool RegisterUI(NodeControlType type, Type controlType,Type viewModelType)
|
public bool RegisterUI(NodeControlType type, Type controlType,Type viewModelType)
|
||||||
{
|
{
|
||||||
if (!FlowNodeTypes.TryGetValue(type, out var nodeMVVM))
|
if (!FlowNodeTypes.TryGetValue(type, out var nodeMVVM))
|
||||||
{
|
{
|
||||||
@@ -94,7 +96,7 @@ namespace Serein.NodeFlow
|
|||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
/// <param name="nodeMVVM"></param>
|
/// <param name="nodeMVVM"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool TryGetType(NodeControlType type, out NodeMVVM nodeMVVM)
|
public bool TryGetType(NodeControlType type, out NodeMVVM nodeMVVM)
|
||||||
{
|
{
|
||||||
if( FlowNodeTypes.TryGetValue(type, out nodeMVVM))
|
if( FlowNodeTypes.TryGetValue(type, out nodeMVVM))
|
||||||
{
|
{
|
||||||
@@ -12,6 +12,7 @@
|
|||||||
<RepositoryUrl>https://github.com/fhhyyp/serein-flow</RepositoryUrl>
|
<RepositoryUrl>https://github.com/fhhyyp/serein-flow</RepositoryUrl>
|
||||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||||
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
|
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
|
||||||
|
<LangVersion>latest</LangVersion>
|
||||||
|
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
|
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ namespace Serein.NodeFlow.Env
|
|||||||
|
|
||||||
};
|
};
|
||||||
this.FlowLibraryManagement = new FlowLibraryManagement(this); // 实例化类库管理
|
this.FlowLibraryManagement = new FlowLibraryManagement(this); // 实例化类库管理
|
||||||
|
this.NodeMVVMManagement = new NodeMVVMManagement();
|
||||||
#region 注册基本节点类型
|
#region 注册基本节点类型
|
||||||
NodeMVVMManagement.RegisterModel(NodeControlType.UI, typeof(SingleUINode)); // 动作节点
|
NodeMVVMManagement.RegisterModel(NodeControlType.UI, typeof(SingleUINode)); // 动作节点
|
||||||
|
|
||||||
@@ -214,6 +214,11 @@ namespace Serein.NodeFlow.Env
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public UIContextOperation UIContextOperation { get; set; }
|
public UIContextOperation UIContextOperation { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 节点视图模型管理类
|
||||||
|
/// </summary>
|
||||||
|
public NodeMVVMManagement NodeMVVMManagement { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 信息输出等级
|
/// 信息输出等级
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -654,12 +659,12 @@ namespace Serein.NodeFlow.Env
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载本地程序集
|
/// 加载本地程序集
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assembly"></param>
|
/// <param name="flowLibrary"></param>
|
||||||
public void LoadLibrary(Assembly assembly)
|
public void LoadLibrary(FlowLibrary flowLibrary)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
(var libraryInfo, var mdInfos) = FlowLibraryManagement.LoadLibraryOfPath(assembly);
|
(var libraryInfo, var mdInfos) = FlowLibraryManagement.LoadLibraryOfPath(flowLibrary);
|
||||||
if (mdInfos.Count > 0)
|
if (mdInfos.Count > 0)
|
||||||
{
|
{
|
||||||
UIContextOperation?.Invoke(() => OnDllLoad?.Invoke(new LoadDllEventArgs(libraryInfo, mdInfos))); // 通知UI创建dll面板显示
|
UIContextOperation?.Invoke(() => OnDllLoad?.Invoke(new LoadDllEventArgs(libraryInfo, mdInfos))); // 通知UI创建dll面板显示
|
||||||
|
|||||||
@@ -82,6 +82,10 @@ namespace Serein.NodeFlow.Env
|
|||||||
public IFlowEnvironment CurrentEnv { get => currentFlowEnvironment; }
|
public IFlowEnvironment CurrentEnv { get => currentFlowEnvironment; }
|
||||||
|
|
||||||
public UIContextOperation UIContextOperation => currentFlowEnvironment.UIContextOperation;
|
public UIContextOperation UIContextOperation => currentFlowEnvironment.UIContextOperation;
|
||||||
|
/// <summary>
|
||||||
|
/// 节点视图模型管理类
|
||||||
|
/// </summary>
|
||||||
|
public NodeMVVMManagement NodeMVVMManagement => currentFlowEnvironment.NodeMVVMManagement;
|
||||||
|
|
||||||
public ISereinIOC IOC => (ISereinIOC)currentFlowEnvironment;
|
public ISereinIOC IOC => (ISereinIOC)currentFlowEnvironment;
|
||||||
|
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ namespace Serein.NodeFlow.Env
|
|||||||
|
|
||||||
public IFlowEnvironment CurrentEnv => this;
|
public IFlowEnvironment CurrentEnv => this;
|
||||||
public UIContextOperation UIContextOperation { get; }
|
public UIContextOperation UIContextOperation { get; }
|
||||||
|
public NodeMVVMManagement NodeMVVMManagement { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 标示是否正在加载项目
|
/// 标示是否正在加载项目
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace Serein.NodeFlow
|
|||||||
|
|
||||||
// 尝试获取需要创建的节点类型
|
// 尝试获取需要创建的节点类型
|
||||||
|
|
||||||
if (!NodeMVVMManagement.TryGetType(nodeControlType, out var nodeMVVM) || nodeMVVM.ModelType == null)
|
if (!env.NodeMVVMManagement.TryGetType(nodeControlType, out var nodeMVVM) || nodeMVVM.ModelType == null)
|
||||||
{
|
{
|
||||||
throw new Exception($"无法创建{nodeControlType}节点,节点类型尚未注册。");
|
throw new Exception($"无法创建{nodeControlType}节点,节点类型尚未注册。");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,13 +101,13 @@ namespace Serein.NodeFlow.Tool
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
ms.Seek(0, SeekOrigin.Begin);
|
ms.Seek(0, SeekOrigin.Begin);
|
||||||
|
var t12 = AppContext.BaseDirectory;
|
||||||
var assembly = Assembly.Load(ms.ToArray());
|
var assembly = Assembly.Load(ms.ToArray());
|
||||||
var t1 = assembly.Location;
|
var t1 = assembly.Location;
|
||||||
var t = assembly.GetType().Assembly.Location;
|
var t = assembly.GetType().Assembly.Location;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 保存
|
// 保存
|
||||||
|
|
||||||
compilation.Emit(savePath);
|
compilation.Emit(savePath);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace Serein.NodeFlow
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class FlowLibrary
|
public class FlowLibrary
|
||||||
{
|
{
|
||||||
private readonly Assembly _assembly;
|
public Assembly Assembly { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -36,16 +36,16 @@ namespace Serein.NodeFlow
|
|||||||
|
|
||||||
public FlowLibrary(Assembly assembly)
|
public FlowLibrary(Assembly assembly)
|
||||||
{
|
{
|
||||||
this._assembly = assembly;
|
this.Assembly = assembly;
|
||||||
this.FullName = Path.GetFileName(_assembly.Location);
|
this.FullName = Path.GetFileName(Assembly.Location);
|
||||||
|
|
||||||
this.FilePath = _assembly.Location;
|
this.FilePath = Assembly.Location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FlowLibrary(Assembly assembly,
|
public FlowLibrary(Assembly assembly,
|
||||||
string filePath)
|
string filePath)
|
||||||
{
|
{
|
||||||
this._assembly = assembly;
|
this.Assembly = assembly;
|
||||||
this.FullName = Path.GetFileName(filePath); ;
|
this.FullName = Path.GetFileName(filePath); ;
|
||||||
this.FilePath = filePath;
|
this.FilePath = filePath;
|
||||||
}
|
}
|
||||||
@@ -92,7 +92,7 @@ namespace Serein.NodeFlow
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public NodeLibraryInfo ToInfo()
|
public NodeLibraryInfo ToInfo()
|
||||||
{
|
{
|
||||||
var assemblyName = _assembly.GetName().Name;
|
var assemblyName = Assembly.GetName().Name;
|
||||||
return new NodeLibraryInfo
|
return new NodeLibraryInfo
|
||||||
{
|
{
|
||||||
AssemblyName = assemblyName,
|
AssemblyName = assemblyName,
|
||||||
@@ -111,7 +111,7 @@ namespace Serein.NodeFlow
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool LoadAssembly()
|
public bool LoadAssembly()
|
||||||
{
|
{
|
||||||
Assembly assembly = this._assembly;
|
Assembly assembly = this.Assembly;
|
||||||
#region 检查入参
|
#region 检查入参
|
||||||
|
|
||||||
// 加载DLL,创建 MethodDetails、实例作用对象、委托方法
|
// 加载DLL,创建 MethodDetails、实例作用对象、委托方法
|
||||||
|
|||||||
@@ -49,26 +49,31 @@ namespace Serein.NodeFlow.Tool
|
|||||||
|
|
||||||
var flowAlc = new FlowLibraryAssemblyContext(sereinFlowBaseLibraryPath, Path.GetFileName(libraryfilePath));
|
var flowAlc = new FlowLibraryAssemblyContext(sereinFlowBaseLibraryPath, Path.GetFileName(libraryfilePath));
|
||||||
var assembly = flowAlc.LoadFromAssemblyPath(libraryfilePath); // 加载指定路径的程序集
|
var assembly = flowAlc.LoadFromAssemblyPath(libraryfilePath); // 加载指定路径的程序集
|
||||||
var reulst = LoadDllNodeInfo(assembly);
|
|
||||||
if(reulst.Item1 is null || reulst.Item2.Count == 0)
|
var flowLibrary = new FlowLibrary(assembly);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var reulst = LoadFlowLibrary(flowLibrary);
|
||||||
|
return reulst;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
{
|
{
|
||||||
flowAlc?.Unload(); // 卸载程序集
|
flowAlc?.Unload(); // 卸载程序集
|
||||||
flowAlc = null;
|
flowAlc = null;
|
||||||
GC.Collect(); // 强制触发GC确保卸载成功
|
GC.Collect(); // 强制触发GC确保卸载成功
|
||||||
GC.WaitForPendingFinalizers();
|
GC.WaitForPendingFinalizers();
|
||||||
throw new Exception("从文件加载DLL失败:"+ libraryfilePath);
|
throw;
|
||||||
}
|
}
|
||||||
return reulst;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载类库
|
/// 加载类库
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assembly"></param>
|
/// <param name="flowLibrary"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public (NodeLibraryInfo, List<MethodDetailsInfo>) LoadLibraryOfPath(Assembly assembly)
|
public (NodeLibraryInfo, List<MethodDetailsInfo>) LoadLibraryOfPath(FlowLibrary flowLibrary)
|
||||||
{
|
{
|
||||||
return LoadDllNodeInfo(assembly);
|
return LoadFlowLibrary(flowLibrary);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -235,38 +240,48 @@ namespace Serein.NodeFlow.Tool
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly static string SereinBaseLibrary = $"{nameof(Serein)}.{nameof(Serein.Library)}.dll";
|
public readonly static string SereinBaseLibrary = $"{nameof(Serein)}.{nameof(Serein.Library)}.dll";
|
||||||
|
|
||||||
private (NodeLibraryInfo, List<MethodDetailsInfo>) LoadDllNodeInfo(Assembly assembly)
|
//private (NodeLibraryInfo, List<MethodDetailsInfo>) LoadDllNodeInfo(Assembly assembly)
|
||||||
{
|
//{
|
||||||
|
|
||||||
|
// if (assembly.FullName?.ToString().Equals(typeof(IFlowEnvironment).Assembly.FullName?.ToString()) == true)
|
||||||
|
// {
|
||||||
|
|
||||||
|
// // 加载基础依赖
|
||||||
|
// return LoadAssembly(typeof(IFlowEnvironment).Assembly);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// var assembly_result = LoadAssembly(assembly);
|
||||||
|
// return assembly_result;
|
||||||
|
// }
|
||||||
|
// catch (Exception)
|
||||||
|
// {
|
||||||
|
// return (null,[]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private (NodeLibraryInfo, List<MethodDetailsInfo>) LoadFlowLibrary(FlowLibrary flowLibrary)
|
||||||
|
{
|
||||||
|
var assembly = flowLibrary.Assembly;
|
||||||
if (assembly.FullName?.ToString().Equals(typeof(IFlowEnvironment).Assembly.FullName?.ToString()) == true)
|
if (assembly.FullName?.ToString().Equals(typeof(IFlowEnvironment).Assembly.FullName?.ToString()) == true)
|
||||||
{
|
{
|
||||||
// 加载基础依赖
|
// 加载基础依赖
|
||||||
return LoadAssembly(typeof(IFlowEnvironment).Assembly);
|
flowLibrary = new FlowLibrary(typeof(IFlowEnvironment).Assembly);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var assembly_result = LoadAssembly(assembly);
|
|
||||||
return assembly_result;
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
return (null,[]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
var assmblyName = assembly.GetName().Name;
|
||||||
|
if (!string.IsNullOrEmpty(assmblyName) && _myFlowLibrarys.ContainsKey(assmblyName))
|
||||||
|
{
|
||||||
|
throw new Exception($"程序集[{assembly.GetName().FullName}]已经加载过!");
|
||||||
|
}
|
||||||
|
|
||||||
private (NodeLibraryInfo, List<MethodDetailsInfo>) LoadAssembly(Assembly assembly)
|
|
||||||
{
|
|
||||||
if (_myFlowLibrarys.ContainsKey(assembly.GetName().Name))
|
|
||||||
{
|
|
||||||
throw new Exception($"程序集[{assembly.GetName().FullName}]已经加载过!");
|
|
||||||
}
|
|
||||||
|
|
||||||
FlowLibrary flowLibrary = new FlowLibrary(assembly);
|
|
||||||
var loadResult = flowLibrary.LoadAssembly(); // 加载程序集
|
var loadResult = flowLibrary.LoadAssembly(); // 加载程序集
|
||||||
if (loadResult)
|
if (loadResult)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -164,15 +164,15 @@ namespace Serein.Workbench
|
|||||||
IOCObjectViewer.SelectObj += ViewObjectViewer.LoadObjectInformation; // 使选择 IOC容器视图 的某项(对象)时,可以在 数据视图 呈现数据
|
IOCObjectViewer.SelectObj += ViewObjectViewer.LoadObjectInformation; // 使选择 IOC容器视图 的某项(对象)时,可以在 数据视图 呈现数据
|
||||||
|
|
||||||
#region 为 NodeControlType 枚举 不同项添加对应的 Control类型 、 ViewModel类型
|
#region 为 NodeControlType 枚举 不同项添加对应的 Control类型 、 ViewModel类型
|
||||||
NodeMVVMManagement.RegisterUI(NodeControlType.UI, typeof(UINodeControl), typeof(UINodeControlViewModel));
|
EnvDecorator.NodeMVVMManagement.RegisterUI(NodeControlType.UI, typeof(UINodeControl), typeof(UINodeControlViewModel));
|
||||||
NodeMVVMManagement.RegisterUI(NodeControlType.Action, typeof(ActionNodeControl), typeof(ActionNodeControlViewModel));
|
EnvDecorator.NodeMVVMManagement.RegisterUI(NodeControlType.Action, typeof(ActionNodeControl), typeof(ActionNodeControlViewModel));
|
||||||
NodeMVVMManagement.RegisterUI(NodeControlType.Flipflop, typeof(FlipflopNodeControl), typeof(FlipflopNodeControlViewModel));
|
EnvDecorator.NodeMVVMManagement.RegisterUI(NodeControlType.Flipflop, typeof(FlipflopNodeControl), typeof(FlipflopNodeControlViewModel));
|
||||||
NodeMVVMManagement.RegisterUI(NodeControlType.ExpOp, typeof(ExpOpNodeControl), typeof(ExpOpNodeControlViewModel));
|
EnvDecorator.NodeMVVMManagement.RegisterUI(NodeControlType.ExpOp, typeof(ExpOpNodeControl), typeof(ExpOpNodeControlViewModel));
|
||||||
NodeMVVMManagement.RegisterUI(NodeControlType.ExpCondition, typeof(ConditionNodeControl), typeof(ConditionNodeControlViewModel));
|
EnvDecorator.NodeMVVMManagement.RegisterUI(NodeControlType.ExpCondition, typeof(ConditionNodeControl), typeof(ConditionNodeControlViewModel));
|
||||||
NodeMVVMManagement.RegisterUI(NodeControlType.ConditionRegion, typeof(ConditionRegionControl), typeof(ConditionRegionNodeControlViewModel));
|
EnvDecorator.NodeMVVMManagement.RegisterUI(NodeControlType.ConditionRegion, typeof(ConditionRegionControl), typeof(ConditionRegionNodeControlViewModel));
|
||||||
NodeMVVMManagement.RegisterUI(NodeControlType.GlobalData, typeof(GlobalDataControl), typeof(GlobalDataNodeControlViewModel));
|
EnvDecorator.NodeMVVMManagement.RegisterUI(NodeControlType.GlobalData, typeof(GlobalDataControl), typeof(GlobalDataNodeControlViewModel));
|
||||||
NodeMVVMManagement.RegisterUI(NodeControlType.Script, typeof(ScriptNodeControl), typeof(ScriptNodeControlViewModel));
|
EnvDecorator.NodeMVVMManagement.RegisterUI(NodeControlType.Script, typeof(ScriptNodeControl), typeof(ScriptNodeControlViewModel));
|
||||||
NodeMVVMManagement.RegisterUI(NodeControlType.NetScript, typeof(NetScriptNodeControl), typeof(NetScriptNodeControlViewModel));
|
EnvDecorator.NodeMVVMManagement.RegisterUI(NodeControlType.NetScript, typeof(NetScriptNodeControl), typeof(NetScriptNodeControlViewModel));
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
@@ -733,7 +733,7 @@ namespace Serein.Workbench
|
|||||||
|
|
||||||
PositionOfUI position = eventArgs.Position;
|
PositionOfUI position = eventArgs.Position;
|
||||||
|
|
||||||
if(!NodeMVVMManagement.TryGetType(nodeModel.ControlType, out var nodeMVVM))
|
if(!EnvDecorator.NodeMVVMManagement.TryGetType(nodeModel.ControlType, out var nodeMVVM))
|
||||||
{
|
{
|
||||||
SereinEnv.WriteLine(InfoType.INFO, $"无法创建{nodeModel.ControlType}节点,节点类型尚未注册。");
|
SereinEnv.WriteLine(InfoType.INFO, $"无法创建{nodeModel.ControlType}节点,节点类型尚未注册。");
|
||||||
return;
|
return;
|
||||||
@@ -2707,11 +2707,11 @@ public class FlowLibrary
|
|||||||
|
|
||||||
DynamicCompilerView dynamicCompilerView = new DynamicCompilerView();
|
DynamicCompilerView dynamicCompilerView = new DynamicCompilerView();
|
||||||
dynamicCompilerView.ScriptCode = script;
|
dynamicCompilerView.ScriptCode = script;
|
||||||
dynamicCompilerView.OnCompileComplete = (assembly) =>
|
dynamicCompilerView.OnCompileComplete = (flowLibrary) =>
|
||||||
{
|
{
|
||||||
if(EnvDecorator.CurrentEnv is FlowEnvironment environment)
|
if(EnvDecorator.CurrentEnv is FlowEnvironment environment)
|
||||||
{
|
{
|
||||||
environment.LoadLibrary(assembly);
|
environment.LoadLibrary(flowLibrary);
|
||||||
}
|
}
|
||||||
//EnvDecorator.LoadLibrary
|
//EnvDecorator.LoadLibrary
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -71,9 +71,8 @@ public class FlowLibrary
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void OnCompileComplete(System.Reflection.Assembly assembly)
|
private static void OnCompileComplete(FlowLibrary flowLibrary)
|
||||||
{
|
{
|
||||||
FlowLibrary flowLibrary = new FlowLibrary(assembly);
|
|
||||||
var loadResult = flowLibrary.LoadAssembly(); // 动态编译完成后加载程序集
|
var loadResult = flowLibrary.LoadAssembly(); // 动态编译完成后加载程序集
|
||||||
if (!loadResult)
|
if (!loadResult)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
|
using Serein.NodeFlow;
|
||||||
using Serein.NodeFlow.Tool;
|
using Serein.NodeFlow.Tool;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -33,7 +34,7 @@ namespace Serein.Workbench.Themes
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 编译成功回调
|
/// 编译成功回调
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Action<Assembly> OnCompileComplete { get; set; }
|
public Action<FlowLibrary> OnCompileComplete { get; set; }
|
||||||
public DynamicCompilerView()
|
public DynamicCompilerView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -127,16 +128,17 @@ namespace Serein.Workbench.Themes
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
txtErrors.Clear();
|
txtErrors.Clear();
|
||||||
string code = codeEditor.Text;
|
var code = codeEditor.Text;
|
||||||
Assembly assembly = _compiler.Compile(code, textboxAssemblyName.Text);
|
var path = textboxAssemblyName.Text;
|
||||||
|
Assembly assembly = _compiler.Compile(code, path);
|
||||||
|
|
||||||
|
FlowLibrary flowLibrary = new FlowLibrary(assembly, path);
|
||||||
|
|
||||||
if (assembly != null)
|
if (assembly != null)
|
||||||
{
|
{
|
||||||
txtErrors.Text = "编译成功!";
|
txtErrors.Text = "编译成功!";
|
||||||
txtErrors.Background = System.Windows.Media.Brushes.LightGreen;
|
txtErrors.Background = System.Windows.Media.Brushes.LightGreen;
|
||||||
OnCompileComplete.Invoke(assembly);
|
OnCompileComplete.Invoke(flowLibrary);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user