修复了无法创建连线

This commit is contained in:
fengjiayi
2024-10-01 17:34:08 +08:00
parent 4bca28f468
commit 7a9f7b7bf3
2 changed files with 10 additions and 9 deletions

View File

@@ -41,7 +41,7 @@ namespace Serein.NodeFlow.Base
/// <summary>
/// 节点guid
/// </summary>
public string Guid { get; set; } = string.Empty;
public string Guid { get; set; }
/// <summary>
/// 显示名称

View File

@@ -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();