NodeMVVMManagement不再是静态类,而是运行环境内部的成员。

This commit is contained in:
fengjiayi
2025-03-18 12:33:54 +08:00
parent fffb22b3a8
commit 87402ec7ea
14 changed files with 110 additions and 77 deletions

View File

@@ -164,15 +164,15 @@ namespace Serein.Workbench
IOCObjectViewer.SelectObj += ViewObjectViewer.LoadObjectInformation; // 使选择 IOC容器视图 的某项(对象)时,可以在 数据视图 呈现数据
#region NodeControlType Control类型 ViewModel类型
NodeMVVMManagement.RegisterUI(NodeControlType.UI, typeof(UINodeControl), typeof(UINodeControlViewModel));
NodeMVVMManagement.RegisterUI(NodeControlType.Action, typeof(ActionNodeControl), typeof(ActionNodeControlViewModel));
NodeMVVMManagement.RegisterUI(NodeControlType.Flipflop, typeof(FlipflopNodeControl), typeof(FlipflopNodeControlViewModel));
NodeMVVMManagement.RegisterUI(NodeControlType.ExpOp, typeof(ExpOpNodeControl), typeof(ExpOpNodeControlViewModel));
NodeMVVMManagement.RegisterUI(NodeControlType.ExpCondition, typeof(ConditionNodeControl), typeof(ConditionNodeControlViewModel));
NodeMVVMManagement.RegisterUI(NodeControlType.ConditionRegion, typeof(ConditionRegionControl), typeof(ConditionRegionNodeControlViewModel));
NodeMVVMManagement.RegisterUI(NodeControlType.GlobalData, typeof(GlobalDataControl), typeof(GlobalDataNodeControlViewModel));
NodeMVVMManagement.RegisterUI(NodeControlType.Script, typeof(ScriptNodeControl), typeof(ScriptNodeControlViewModel));
NodeMVVMManagement.RegisterUI(NodeControlType.NetScript, typeof(NetScriptNodeControl), typeof(NetScriptNodeControlViewModel));
EnvDecorator.NodeMVVMManagement.RegisterUI(NodeControlType.UI, typeof(UINodeControl), typeof(UINodeControlViewModel));
EnvDecorator.NodeMVVMManagement.RegisterUI(NodeControlType.Action, typeof(ActionNodeControl), typeof(ActionNodeControlViewModel));
EnvDecorator.NodeMVVMManagement.RegisterUI(NodeControlType.Flipflop, typeof(FlipflopNodeControl), typeof(FlipflopNodeControlViewModel));
EnvDecorator.NodeMVVMManagement.RegisterUI(NodeControlType.ExpOp, typeof(ExpOpNodeControl), typeof(ExpOpNodeControlViewModel));
EnvDecorator.NodeMVVMManagement.RegisterUI(NodeControlType.ExpCondition, typeof(ConditionNodeControl), typeof(ConditionNodeControlViewModel));
EnvDecorator.NodeMVVMManagement.RegisterUI(NodeControlType.ConditionRegion, typeof(ConditionRegionControl), typeof(ConditionRegionNodeControlViewModel));
EnvDecorator.NodeMVVMManagement.RegisterUI(NodeControlType.GlobalData, typeof(GlobalDataControl), typeof(GlobalDataNodeControlViewModel));
EnvDecorator.NodeMVVMManagement.RegisterUI(NodeControlType.Script, typeof(ScriptNodeControl), typeof(ScriptNodeControlViewModel));
EnvDecorator.NodeMVVMManagement.RegisterUI(NodeControlType.NetScript, typeof(NetScriptNodeControl), typeof(NetScriptNodeControlViewModel));
#endregion
@@ -733,7 +733,7 @@ namespace Serein.Workbench
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}节点,节点类型尚未注册。");
return;
@@ -2707,11 +2707,11 @@ public class FlowLibrary
DynamicCompilerView dynamicCompilerView = new DynamicCompilerView();
dynamicCompilerView.ScriptCode = script;
dynamicCompilerView.OnCompileComplete = (assembly) =>
dynamicCompilerView.OnCompileComplete = (flowLibrary) =>
{
if(EnvDecorator.CurrentEnv is FlowEnvironment environment)
{
environment.LoadLibrary(assembly);
environment.LoadLibrary(flowLibrary);
}
//EnvDecorator.LoadLibrary
};

View File

@@ -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(); // 动态编译完成后加载程序集
if (!loadResult)
{

View File

@@ -1,4 +1,5 @@
using Microsoft.Win32;
using Serein.NodeFlow;
using Serein.NodeFlow.Tool;
using System;
using System.Collections.Generic;
@@ -33,7 +34,7 @@ namespace Serein.Workbench.Themes
/// <summary>
/// 编译成功回调
/// </summary>
public Action<Assembly> OnCompileComplete { get; set; }
public Action<FlowLibrary> OnCompileComplete { get; set; }
public DynamicCompilerView()
{
InitializeComponent();
@@ -127,16 +128,17 @@ namespace Serein.Workbench.Themes
try
{
txtErrors.Clear();
string code = codeEditor.Text;
Assembly assembly = _compiler.Compile(code, textboxAssemblyName.Text);
var code = codeEditor.Text;
var path = textboxAssemblyName.Text;
Assembly assembly = _compiler.Compile(code, path);
FlowLibrary flowLibrary = new FlowLibrary(assembly, path);
if (assembly != null)
{
txtErrors.Text = "编译成功!";
txtErrors.Background = System.Windows.Media.Brushes.LightGreen;
OnCompileComplete.Invoke(assembly);
OnCompileComplete.Invoke(flowLibrary);
count++;
}
}