Lazy <ISolutionExplorerNode> GetParent(IVsHierarchyItem hierarchy) => hierarchy.Parent == null ? null : new Lazy <ISolutionExplorerNode>(() => nodeFactory.CreateNode(hierarchy.Parent));
/// <summary> /// Creates a new child node using the node factory received in the constructor. /// </summary> /// <param name="item">The hierarchy node to create the child node for.</param> /// <remarks> /// This method is used for example when the node exposes child node creation APIs, such as /// the <see cref="FolderNode"/>. /// </remarks> protected virtual ISolutionExplorerNode CreateNode(IVsHierarchyItem item) => nodeFactory.CreateNode(item);
/// <summary> /// Initializes a new instance of the <see cref="SolutionExplorerNode"/> class. /// </summary> /// <param name="nodeKind">Kind of the node.</param> /// <param name="hierarchyItem">The underlying hierarchy represented by this node.</param> /// <param name="nodeFactory">The factory for child nodes.</param> /// <param name="adapter">The adapter service that implements the smart cast <see cref="ISolutionExplorerNode.As{T}"/>.</param> protected SolutionExplorerNode( SolutionNodeKind nodeKind, IVsHierarchyItem hierarchyItem, ISolutionExplorerNodeFactory nodeFactory, IAdapterService adapter, JoinableLazy <IVsUIHierarchyWindow> solutionExplorer) { Guard.NotNull(nameof(hierarchyItem), hierarchyItem); Guard.NotNull(nameof(nodeFactory), nodeFactory); Guard.NotNull(nameof(adapter), adapter); Guard.NotNull(nameof(solutionExplorer), solutionExplorer); this.hierarchyItem = hierarchyItem; this.nodeFactory = nodeFactory; this.adapter = adapter; this.solutionExplorer = solutionExplorer; Kind = nodeKind; parent = hierarchyItem.Parent == null ? new Lazy <ISolutionExplorerNode>(() => null) : new Lazy <ISolutionExplorerNode>(() => nodeFactory.CreateNode(hierarchyItem.Parent)); name = new Lazy <string>(() => hierarchyItem.GetProperty(VsHierarchyPropID.Name, "")); Func <bool> getHiddenProperty = () => this.hierarchyItem.GetProperty(VsHierarchyPropID.IsHiddenItem, false); isHidden = hierarchyItem.Parent != null ? new Lazy <bool>(() => getHiddenProperty() || parent.Value.IsHidden) : new Lazy <bool>(() => getHiddenProperty()); solutionNode = new JoinableLazy <ISolutionNode>(() => this.nodeFactory.CreateNode(this.hierarchyItem.GetTopMost()) as ISolutionNode, true); if (hierarchyItem.HierarchyIdentity.IsNestedItem) { hierarchy = hierarchyItem.HierarchyIdentity.NestedHierarchy; itemId = hierarchyItem.HierarchyIdentity.NestedItemID; } else { hierarchy = hierarchyItem.HierarchyIdentity.Hierarchy; itemId = hierarchyItem.HierarchyIdentity.ItemID; } }