Example #1
0
        ///
        private RedDotNode <T> Visit(bool isCreate, params string[] args)
        {
            if (args == null || args.Length <= 0)
            {
                return(null);
            }

            var node = this;

            foreach (var nodeName in args)
            {
                if (string.IsNullOrEmpty(nodeName))
                {
                    return(null);
                }

                if (isCreate)
                {
                    node.children = node.children ?? new Dictionary <string, RedDotNode <T> >();

                    if (!node.children.ContainsKey(nodeName))
                    {
                        //信息附加
                        var newNode = new RedDotNode <T>();
                        newNode.name   = nodeName;
                        newNode.parent = node;

                        node.children[nodeName] = newNode;
                    }
                    node.children.TryGetValue(nodeName, out node);
                }
                else
                {
                    if (node == null)
                    {
                        return(null);
                    }

                    if (node.children == null)
                    {
                        return(null);
                    }

                    node.children.TryGetValue(nodeName, out node);
                }
            }
            return(node);
        }
Example #2
0
 private RedDotNode <RedDotData> GetTreeRoot()
 {
     m_treeRoot = m_treeRoot ?? new RedDotNode <RedDotData>();
     return(m_treeRoot);
 }