我在嵌套数据类的 Node 代码的设置器中遇到堆栈溢出异常
嵌套数据类 Desc 应该如何在基类和派生类中处理,以便我可以在主窗口中创建的新节点中使用这些数据?
namespace Lib
{
// Nested Data Class
public class Desc
{
public Desc(string shape, Nullable<bool>[] inpins)
{
this.inpins = inpins;
}
string shape { get; set; }
Nullable<bool>[] inpins { get; set; }
}
// Base class drived from ShapeNode class in vendor's framework
public class Node : ShapeNode
{
public Node()
{
}
// Make a copy of Node
public Node(Node copy)
: base(copy)
{
Text = copy.Text;
NodeId = copy.NodeId;
}
public virtual Node Clone()
{
return new Node(this);
}
// Base Constructor
public Node(string Text, Desc NodeId)
{
this.Text = Text;
this.NodeId = NodeId;
}
new public string Text { get { return base.Text; } set { base.Text = value; } }
public Desc NodeId { get { return NodeId; } set { NodeId = value; }
}
}
namespace Test
{
// Main Window code
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
nodes = new Node[]
{ new A(
"TESTA",
new Desc(new Nullable<bool>[]{false, false})),
new B(
"TESTB",
new Desc(new Nullable<bool>[] {false, false, false}))
}
}
}