IOC容器添加构造函数注入(DLL类中使用AutoRegisterAttribute特性标注的类,会在流程启动时自动注册),提高可读性。

This commit is contained in:
fengjiayi
2024-09-30 02:45:49 +08:00
parent 7a310ff1df
commit ccf539b90f
23 changed files with 615 additions and 280 deletions

View File

@@ -283,16 +283,13 @@ namespace Serein.WorkBench
/// <summary>
/// 加载了DLL文件dll内容
/// </summary>
private void FlowEnvironment_DllLoadEvent(LoadDLLEventArgs eventArgs)
private void FlowEnvironment_DllLoadEvent(LoadDllEventArgs eventArgs)
{
this.Dispatcher.Invoke(() => {
Assembly assembly = eventArgs.Assembly;
NodeLibrary nodeLibrary = eventArgs.NodeLibrary;
List<MethodDetails> methodDetailss = eventArgs.MethodDetailss;
var dllControl = new DllControl
{
Header = "DLL name : " + assembly.GetName().Name // 设置控件标题为程序集名称
};
var dllControl = new DllControl(nodeLibrary);
foreach (var methodDetails in methodDetailss)
{
@@ -306,6 +303,21 @@ namespace Serein.WorkBench
break;
}
}
var menu = new ContextMenu();
menu.Items.Add(CreateMenuItem("卸载", (s,e) =>
{
if (this.FlowEnvironment.RemoteDll(nodeLibrary.Assembly.FullName))
{
DllStackPanel.Children.Remove(dllControl);
}
else
{
Console.WriteLine("卸载失败");
}
}));
dllControl.ContextMenu = menu;
DllStackPanel.Children.Add(dllControl); // 将控件添加到界面上显示
});
@@ -775,26 +787,26 @@ namespace Serein.WorkBench
/// </summary>
/// <param name="regionControl"></param>
/// <param name="childNodes"></param>
private void AddNodeControlInRegeionControl(NodeControlBase regionControl, NodeInfo[] childNodes)
{
foreach (var childNode in childNodes)
{
if (FlowEnvironment.TryGetMethodDetails(childNode.MethodName, out MethodDetails md))
{
var childNodeControl = CreateNodeControlOfNodeInfo(childNode, md);
if (childNodeControl is null)
{
Console.WriteLine($"无法为节点类型创建节点控件: {childNode.MethodName}\r\n");
continue;
}
//private void AddNodeControlInRegeionControl(NodeControlBase regionControl, NodeInfo[] childNodes)
//{
// foreach (var childNode in childNodes)
// {
// if (FlowEnvironment.TryGetMethodDetails(childNode.MethodName, out MethodDetails md))
// {
// var childNodeControl = CreateNodeControlOfNodeInfo(childNode, md);
// if (childNodeControl is null)
// {
// Console.WriteLine($"无法为节点类型创建节点控件: {childNode.MethodName}\r\n");
// continue;
// }
if (regionControl is ConditionRegionControl conditionRegion)
{
conditionRegion.AddCondition(childNodeControl);
}
}
}
}
// if (regionControl is ConditionRegionControl conditionRegion)
// {
// conditionRegion.AddCondition(childNodeControl);
// }
// }
// }
//}
#endregion

View File

@@ -1,6 +1,8 @@
using Serein.Library.Entity;
using Serein.Library.Api;
using Serein.Library.Entity;
using Serein.Library.Enums;
using Serein.NodeFlow;
using System.Reflection;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
@@ -18,12 +20,20 @@ namespace Serein.WorkBench.Node.View
/// </summary>
public partial class DllControl : UserControl
{
private readonly NodeLibrary nodeLibrary;
public DllControl()
{
Header = "DLL文件"; // 设置初始值
InitializeComponent();
}
public DllControl(NodeLibrary nodeLibrary)
{
this.nodeLibrary = nodeLibrary;
Header = "DLL name : " + nodeLibrary.Assembly.GetName().Name;
InitializeComponent();
}
/// <summary>
@@ -39,10 +49,6 @@ namespace Serein.WorkBench.Node.View
DependencyProperty.Register("Header", typeof(string), typeof(DllControl), new PropertyMetadata(string.Empty));
/// <summary>
/// 向动作面板添加类型的文本块
/// </summary>