예제 #1
0
        public IDataNode GetNode(string path, IDataNode dataNode)
        {
            IDataNode current = dataNode;

            string[] splitPath = GetSplitPath(path);
            foreach (string s in splitPath)
            {
                current = current.GetChild(s);
                if (current == null)
                {
                    return(null);
                }
            }
            return(current);
        }
예제 #2
0
        /// <summary>
        /// 获取数据结点。
        /// </summary>
        /// <param name="path">相对于 node 的查找路径。</param>
        /// <param name="node">查找起始结点。</param>
        /// <returns>指定位置的数据结点,如果没有找到,则返回空。</returns>
        public IDataNode GetNode(string path, IDataNode node)
        {
            IDataNode current = node ?? m_Root;

            string[] splitPath = GetSplitPath(path);
            foreach (string i in splitPath)
            {
                current = current.GetChild(i);
                if (current == null)
                {
                    return(null);
                }
            }

            return(current);
        }
예제 #3
0
        public void RemoveNode(string path, IDataNode dataNode)
        {
            IDataNode current = dataNode;
            IDataNode parent  = current.Parent;

            string[] splitPath = GetSplitPath(path);
            foreach (string s in splitPath)
            {
                parent  = current;
                current = current.GetChild(s);
                if (current == null)
                {
                    return;
                }
            }
            parent?.RemoveChild(current.Name);
        }
예제 #4
0
        /// <summary>
        /// 移除数据结点。
        /// </summary>
        /// <param name="path">相对于 node 的查找路径。</param>
        /// <param name="node">查找起始结点。</param>
        public void RemoveNode(string path, IDataNode node)
        {
            IDataNode current = node ?? m_Root;
            IDataNode parent  = current.Parent;

            string[] splitPath = GetSplitPath(path);
            foreach (string i in splitPath)
            {
                parent  = current;
                current = current.GetChild(i);
                if (current == null)
                {
                    return;
                }
            }

            if (parent != null)
            {
                parent.RemoveChild(current.Name);
            }
        }