public virtual void Visit(ISolutionExplorerNode node) { if (node != null) { node.Accept(this); } }
ProjectItemContainerNode( ISolutionExplorerNode node, Lazy <ISolutionExplorerNodeFactory> nodeFactory, Lazy <IVsHierarchyItem> hierarchyNode, Lazy <ProjectItems> projectItems) { this.node = node; this.nodeFactory = nodeFactory; this.hierarchyNode = hierarchyNode; this.projectItems = projectItems; }
/// <summary> /// Traverses upwards the ancestors of the specified node. /// </summary> public static IEnumerable <ISolutionExplorerNode> Ancestors(this ISolutionExplorerNode node) { var parent = node.Parent; while (parent != null) { yield return(parent); parent = parent.Parent; } }
/// <summary> /// Returns a relative (logical) path between a node and an ancestor. /// </summary> /// <param name="descendent">The descendent node to calculate the relative path for.</param> /// <param name="ancestor">The ancestor node that determines the root of the relative path.</param> /// <returns>The relative path from <paramref name="ancestor"/> to <paramref name="descendent"/>.</returns> /// <exception cref="System.ArgumentException">The <paramref name="ancestor"/> node is not actually /// an ancestor of <paramref name="descendent"/>.</exception> public static string RelativePathTo (this ISolutionExplorerNode descendent, ISolutionExplorerNode ancestor) { if (!descendent.Ancestors ().Any (node => node.Equals (ancestor) || ReferenceEquals(node, ancestor))) throw new ArgumentException (Strings.ISolutionExplorerNodeExtensions.NotAncestor (ancestor, descendent)); return string.Join (Path.DirectorySeparatorChar.ToString (), descendent .Ancestors () .TakeWhile (node => !node.Equals (ancestor) && !ReferenceEquals(node, ancestor)) .Select (node => node.Name) .Reverse () .Concat (new[] { descendent.Name })); }
protected override void DefaultVisit(ISolutionExplorerNode node) { if (node != null) { if (node.Children != null) { foreach (var childNode in node.Children) { childNode.Accept(this); } } } }
/// <summary> /// Returns a relative (logical) path between a node and an ancestor. /// </summary> /// <param name="descendent">The descendent node to calculate the relative path for.</param> /// <param name="ancestor">The ancestor node that determines the root of the relative path.</param> /// <returns>The relative path from <paramref name="ancestor"/> to <paramref name="descendent"/>.</returns> /// <exception cref="System.ArgumentException">The <paramref name="ancestor"/> node is not actually /// an ancestor of <paramref name="descendent"/>.</exception> public static string RelativePathTo(this ISolutionExplorerNode descendent, ISolutionExplorerNode ancestor) { if (!descendent.Ancestors().Any(node => node.Equals(ancestor) || ReferenceEquals(node, ancestor))) { throw new ArgumentException(Strings.ISolutionExplorerNodeExtensions.NotAncestor(ancestor, descendent)); } return(string.Join(Path.DirectorySeparatorChar.ToString(), descendent .Ancestors() .TakeWhile(node => !node.Equals(ancestor) && !ReferenceEquals(node, ancestor)) .Select(node => node.Name) .Reverse() .Concat(new[] { descendent.Name }))); }
private static IEnumerable<ISolutionExplorerNode> DescendantNodes(ISolutionExplorerNode root, Predicate<ISolutionExplorerNode> descendIntoChildren, bool includeSelf) { if (includeSelf) yield return root; Stack<ISolutionExplorerNode> nodes = new Stack<ISolutionExplorerNode>(); nodes.Push(root); while (nodes.Count > 0) { var current = nodes.Pop(); if (descendIntoChildren == null || descendIntoChildren(current)) { foreach (var child in current.Children) { nodes.Push(child); yield return child; } } } }
protected virtual void DefaultVisit(ISolutionExplorerNode node) { }
/// <summary> /// Ends visiting a custom node. /// </summary> /// <param name="customNode">The custom node being visited.</param> /// <returns><see langword="true"/> if the node siblings should be visited; <see langword="false"/> otherwise.</returns> public bool VisitLeaveCustom(ISolutionExplorerNode customNode) => true;
/// <summary> /// Traverses the specified node and all its descendents. The node itself /// also exists in the returned enumeration. To traverse only the /// descendents, traverse its <see cref="ITreeNode.Nodes"/> /// property instead. /// </summary> /// <param name="node">The node to traverse.</param> /// <returns>The <paramref name="node"/> itself and all of its descendent nodes.</returns> public static IEnumerable <ISolutionExplorerNode> Traverse(this ISolutionExplorerNode node) { return(new[] { node }.Traverse(TraverseKind.DepthFirst, x => x.Nodes)); }
/// <summary> /// Begins visiting a custom node. /// </summary> /// <param name="customNode">The custom node being visited.</param> /// <returns><see langword="true"/> if the node children should be visited; <see langword="false"/> otherwise.</returns> public bool VisitEnterCustom (ISolutionExplorerNode customNode) => true;
/// <summary> /// Gets whether the current node equals the given node. /// </summary> public bool Equals(ISolutionExplorerNode other) => Equals(this, other as SolutionExplorerNode);
/// <summary> /// Ends visiting a custom node. /// </summary> /// <param name="customNode">The custom node being visited.</param> /// <returns><see langword="true"/> if the node siblings should be visited; <see langword="false"/> otherwise.</returns> public bool VisitLeaveCustom(ISolutionExplorerNode customNode) { return(true); }
public bool Equals(ISolutionExplorerNode other) { return(false); }
/// <summary> /// Ends visiting a custom node. /// </summary> /// <param name="customNode">The custom node being visited.</param> /// <returns><see langword="true"/> if the node siblings should be visited; <see langword="false"/> otherwise.</returns> public bool VisitLeaveCustom (ISolutionExplorerNode customNode) => true;
/// <summary> /// Begins visiting a custom node. /// </summary> /// <param name="customNode">The custom node being visited.</param> /// <returns><see langword="true"/> if the node children should be visited; <see langword="false"/> otherwise.</returns> public bool VisitEnterCustom(ISolutionExplorerNode customNode) => true;
/// <summary> /// Ends visiting a custom node. /// </summary> /// <param name="customNode">The custom node being visited.</param> /// <returns><see langword="true"/> if the node siblings should be visited; <see langword="false"/> otherwise.</returns> public bool VisitLeaveCustom(ISolutionExplorerNode customNode) { return true; }