public NodeGenerate GetOrCreateChildNode(int childNum) { NodeGenerate childNode; var children = _children; if (children == null) { childNode = new NodeGenerate(childNum, this); _children = new Dictionary <int, NodeGenerate> { { childNum, childNode } }; return(childNode); } if (!children.TryGetValue(childNum, out childNode)) { children[childNum] = childNode = new NodeGenerate(childNum, this); } return(childNode); }
private NodeGenerate(int id, NodeGenerate parentNode) { ID = id; ParentNode = parentNode; }