Пример #1
0
        /// <summary>
        /// Returns an enumerable collection of <see cref="TreeNode"/> objects containing the nodes
        /// of the tree sorted in prefix order.
        /// </summary>
        /// <param name="treeEntity">The tree entity from which to get the nodes.</param>
        /// <returns>
        /// An enumerable collection of <see cref="TreeNode"/> objects containing the nodes
        /// of the tree sorted in prefix order.
        /// </returns>
        public static IEnumerable <TreeNode> GetPrefixTree(this TreeEntityBase treeEntity)
        {
            if (treeEntity is null)
            {
                throw new ArgumentNullException(nameof(treeEntity));
            }

            return(TreeEntityExtensions.GetPrefixTree(treeEntity.RootNode));
        }
Пример #2
0
        /// <summary>
        /// Returns an enumerable collection of <see cref="TreeNode"/> objects containing the nodes
        /// of the tree sorted in prefix order.
        /// </summary>
        /// <param name="node"><see cref="TreeNode"/> to start at.</param>
        /// <returns>
        /// An enumerable collection of <see cref="TreeNode"/> objects containing the nodes
        /// of the tree sorted in prefix order.
        /// </returns>
        private static IEnumerable <TreeNode> GetPrefixTree(TreeNode?node)
        {
            if (node != null)
            {
                yield return(node);

                foreach (TreeNode childNode in node.ChildNodes)
                {
                    foreach (TreeNode subChildNode in TreeEntityExtensions.GetPrefixTree(childNode))
                    {
                        yield return(subChildNode);
                    }
                }
            }
        }