Esempio n. 1
0
        public static ISakiTreeNode FindNodeByTreePath(this ISakiTreeCombinedNode combinedNode, IEnumerable <string> pathParts)
        {
            if (combinedNode.Children == null)
            {
                return(null);
            }

            var name = pathParts.First();

            var node = combinedNode.Children.FirstOrDefault(n => n.Name == name);

            if (node == null)
            {
                return(null);
            }
            if (pathParts.Count() == 1)
            {
                return(node);
            }

            if (node is ISakiTreeCombinedNode cn)
            {
                return(cn.FindNodeByTreePath(pathParts.Skip(1)));
            }

            return(null);
        }
Esempio n. 2
0
        public static ISakiTreeNode FindNodeByTreePath(this ISakiTreeCombinedNode combinedNode, string childTreePath, string nodesHierarchyDelimeter = TreePathStringDelimeter)
        {
            var pathParts = childTreePath.Split(new[] { nodesHierarchyDelimeter }, StringSplitOptions.RemoveEmptyEntries);

            if (pathParts.Length == 0)
            {
                return(null);
            }

            return(combinedNode.FindNodeByTreePath(pathParts));
        }
Esempio n. 3
0
        public static bool IsDescendantdFor(this ISakiTreeNode node, ISakiTreeCombinedNode combinedNode)
        {
            if (combinedNode == null)
            {
                return(false);
            }
            if (node == null)
            {
                return(false);
            }
            if (node.Parent == null)
            {
                return(false);
            }
            if (node.Parent == combinedNode)
            {
                return(true);
            }

            return(combinedNode.Children
                   ?.Any(c => node.IsDescendantdFor(c as ISakiTreeCombinedNode))
                   ?? false);
        }
Esempio n. 4
0
 public static bool HasAscendant(this ISakiTreeNode node, ISakiTreeCombinedNode combinedNode)
 {
     return(!node.IsDescendantdFor(combinedNode));
 }