From 7a9f7b7bf355c805fcbdead7ad4e666d745470df Mon Sep 17 00:00:00 2001
From: fengjiayi <12821976+ning_xi@user.noreply.gitee.com>
Date: Tue, 1 Oct 2024 17:34:08 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E6=97=A0=E6=B3=95?=
=?UTF-8?q?=E5=88=9B=E5=BB=BA=E8=BF=9E=E7=BA=BF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
NodeFlow/Base/NodeModelBaseData.cs | 2 +-
WorkBench/MainWindow.xaml.cs | 17 +++++++++--------
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/NodeFlow/Base/NodeModelBaseData.cs b/NodeFlow/Base/NodeModelBaseData.cs
index b8de691..d89abe0 100644
--- a/NodeFlow/Base/NodeModelBaseData.cs
+++ b/NodeFlow/Base/NodeModelBaseData.cs
@@ -41,7 +41,7 @@ namespace Serein.NodeFlow.Base
///
/// 节点guid
///
- public string Guid { get; set; } = string.Empty;
+ public string Guid { get; set; }
///
/// 显示名称
diff --git a/WorkBench/MainWindow.xaml.cs b/WorkBench/MainWindow.xaml.cs
index 355fff8..2b07d51 100644
--- a/WorkBench/MainWindow.xaml.cs
+++ b/WorkBench/MainWindow.xaml.cs
@@ -2199,7 +2199,10 @@ namespace Serein.WorkBench
{
throw new Exception("无法创建节点控件");
}
-
+ if (string.IsNullOrEmpty(model.Guid))
+ {
+ model.Guid = Guid.NewGuid().ToString();
+ }
var viewModel = Activator.CreateInstance(typeof(TViewModel), [model]);
var controlObj = Activator.CreateInstance(typeof(TControl), [viewModel]);
if (controlObj is TControl control)
@@ -2219,15 +2222,13 @@ namespace Serein.WorkBench
{
var nodeObj = Activator.CreateInstance(typeof(TNode));
- var nodeBase = nodeObj as NodeModelBase;
- if (nodeBase is null)
+ var nodeBase = nodeObj as NodeModelBase ?? throw new Exception("无法创建节点控件");
+
+
+ if (string.IsNullOrEmpty(nodeBase.Guid))
{
- throw new Exception("无法创建节点控件");
+ nodeBase.Guid = Guid.NewGuid().ToString();
}
-
-
- nodeBase.Guid = Guid.NewGuid().ToString();
-
if (methodDetails != null)
{
var md = methodDetails.Clone();