internal VsSolutionHierarchyNode(IVsHierarchy hierarchy, uint itemId, Lazy<VsSolutionHierarchyNode> parent) { if (hierarchy == null) throw new ArgumentNullException(nameof(hierarchy), $"{nameof(hierarchy)} is null."); VsHierarchy = hierarchy; ItemId = itemId; IntPtr nestedHierarchyObj; uint nestedItemId; Guid hierGuid = typeof(IVsHierarchy).GUID; // Check first if this node has a nested hierarchy. If so, then there really are two // identities for this node: 1. hierarchy/itemid 2. nestedHierarchy/nestedItemId. // We will recurse and call EnumHierarchyItems which will display this node using // the inner nestedHierarchy/nestedItemId identity. int hr = hierarchy.GetNestedHierarchy(itemId, ref hierGuid, out nestedHierarchyObj, out nestedItemId); if (hr == VSConstants.S_OK && nestedHierarchyObj != IntPtr.Zero) { IVsHierarchy nestedHierarchy = Marshal.GetObjectForIUnknown(nestedHierarchyObj) as IVsHierarchy; Marshal.Release(nestedHierarchyObj); // we are responsible to release the refcount on the out IntPtr parameter if (nestedHierarchy != null) { VsHierarchy = nestedHierarchy; ItemId = nestedItemId; } } DisplayName = VsHierarchy.GetProperty<string>(__VSHPROPID.VSHPROPID_Name, ItemId); m_parent = parent ?? new Lazy<VsSolutionHierarchyNode>(() => { if (VsHierarchy is IVsSolution) return null; var rootHierarchy = hierarchy.GetProperty<IVsHierarchy>(__VSHPROPID.VSHPROPID_ParentHierarchy, VSConstants.VSITEMID_ROOT); if (rootHierarchy == null) return null; var rootNode = new VsSolutionHierarchyNode(rootHierarchy, VSConstants.VSITEMID_ROOT); var parentNode = new VsSolutionHierarchyNode[] { rootNode } .Concat(rootNode.Children.BreadthFirstTraversal(node => node.Children)) .FirstOrDefault(node => node.Children.Any(child => child.ItemId == ItemId)); if (parentNode == null) return null; return new VsSolutionHierarchyNode(parentNode.VsHierarchy, parentNode.ItemId); }); this.m_serviceProvider = new Lazy<IServiceProvider>(() => { Microsoft.VisualStudio.OLE.Interop.IServiceProvider oleSp; hierarchy.GetSite(out oleSp); return oleSp != null ? new ServiceProvider(oleSp) : GlobalVsServiceProvider.Instance; }); }
public SolutionExplorerNode(SolutionExplorerNodeKind kind, VsSolutionHierarchyNode hierarchyNode, Lazy<ISolutionExplorerNode> parentNode, ISolutionExplorerNodeFactory nodeFactory) { if (nodeFactory == null) throw new ArgumentNullException(nameof(nodeFactory), $"{nameof(nodeFactory)} is null."); if (hierarchyNode == null) throw new ArgumentNullException(nameof(hierarchyNode), $"{nameof(hierarchyNode)} is null."); Kind = kind; NodeFactory = nodeFactory; m_hierarchyNode = hierarchyNode; m_window = new Lazy<IVsUIHierarchyWindow>(() => GetWindow(hierarchyNode.ServiceProvider)); m_parent = parentNode ?? new Lazy<ISolutionExplorerNode>(() => null); Func<bool> getHiddenProperty = () => hierarchyNode.VsHierarchy.GetProperty<bool?>(__VSHPROPID.VSHPROPID_IsHiddenItem, m_hierarchyNode.ItemId).GetValueOrDefault(); m_isHidden = parentNode != null ? new Lazy<bool>(() => getHiddenProperty() || parentNode.Value.IsHidden) : new Lazy<bool>(() => getHiddenProperty()); m_solutionNode = new Lazy<ISolutionNode>(() => { var solutionHierarchy = new VsSolutionHierarchyNode( (IVsHierarchy)m_hierarchyNode.ServiceProvider.GetService<SVsSolution, IVsSolution>(), VSConstants.VSITEMID_ROOT); return new SolutionNode(solutionHierarchy, NodeFactory); }); }
public ProjectNode(VsSolutionHierarchyNode hierarchyNode, Lazy<ISolutionExplorerNode> parentNode, ISolutionExplorerNodeFactory nodeFactory) : base(SolutionExplorerNodeKind.Project, hierarchyNode, parentNode, nodeFactory) { if (parentNode == null) throw new ArgumentNullException(nameof(parentNode), $"{nameof(parentNode)} is null."); m_project = new Lazy<EnvDTE.Project>(() => (EnvDTE.Project)hierarchyNode.ExtenderObject); }
public bool CanCreateFrom(VsSolutionHierarchyNode hierarchy) { var extenderObject = hierarchy.ExtenderObject; var project = extenderObject as EnvDTE.Project; return (extenderObject != null && extenderObject.GetType().FullName == "Microsoft.VisualStudio.Project.Automation.OAProject") || (project != null && !(project.Object is EnvDTE80.SolutionFolder)); }
public ProjectItemNode(SolutionExplorerNodeKind kind, VsSolutionHierarchyNode hierarchyNode, Lazy<ISolutionExplorerNode> parent, ISolutionExplorerNodeFactory nodeFactory) : base(kind, hierarchyNode, parent, nodeFactory) { m_parentProject = new Lazy<IProjectNode>(() => { VsSolutionHierarchyNode parentProjectHierarchy = new VsSolutionHierarchyNode(hierarchyNode.VsHierarchy, VSConstants.VSITEMID_ROOT); return NodeFactory.Create(parentProjectHierarchy, GetParent(parentProjectHierarchy)) as IProjectNode; }); }
public ISolutionExplorerNode Create(VsSolutionHierarchyNode hierarchy, Lazy<ISolutionExplorerNode> parent) { if (hierarchy == null) throw new ArgumentNullException(nameof(hierarchy), $"{nameof(hierarchy)} is null."); if (parent != null) throw new ArgumentException($"{nameof(parent)} must be null for {nameof(SolutionNode)} creation."); return CanCreateFrom(hierarchy) ? new SolutionNode(hierarchy, m_nodeFactory.Value) : null; }
public ISolutionExplorerNode Create(VsSolutionHierarchyNode hierarchy, Lazy<ISolutionExplorerNode> parent) { if (hierarchy == null) throw new ArgumentNullException(nameof(hierarchy), $"{nameof(hierarchy)} is null."); if (parent == null) throw new ArgumentNullException(nameof(parent), $"{nameof(parent)} is null."); return CanCreateFrom(hierarchy) ? new ProjectNode(hierarchy, parent, m_nodeFactory.Value) : null; }
public bool CanCreateFrom(VsSolutionHierarchyNode hierarchy) { if (hierarchy.Parent == null) return false; var item = hierarchy.ExtenderObject as EnvDTE.ProjectItem; var project = hierarchy.Parent.ExtenderObject as EnvDTE.Project; return project != null && item != null && project.Object is EnvDTE80.SolutionFolder; }
public SolutionItemNode(VsSolutionHierarchyNode hierarchyNode, Lazy<ISolutionExplorerNode> parentNode, ISolutionExplorerNodeFactory nodeFactory) : base(SolutionExplorerNodeKind.SolutionItem, hierarchyNode, parentNode, nodeFactory) { m_dteItem = new Lazy<EnvDTE.ProjectItem>(() => (EnvDTE.ProjectItem)hierarchyNode.ExtenderObject); owningFolder = new Lazy<ISolutionFolderNode>(() => { var owningHierarchy = new VsSolutionHierarchyNode(hierarchyNode.VsHierarchy, VSConstants.VSITEMID_ROOT); return NodeFactory.Create(owningHierarchy, GetParent(owningHierarchy)) as ISolutionFolderNode; }); }
public bool CanCreateFrom(VsSolutionHierarchyNode hierarchy) { var projectItem = hierarchy.ExtenderObject as EnvDTE.ProjectItem; return projectItem != null && projectItem.Kind == EnvDTE.Constants.vsProjectItemKindPhysicalFile && !(projectItem.ContainingProject.Object is EnvDTE80.SolutionFolder); }
private Lazy<ISolutionExplorerNode> GetParent(VsSolutionHierarchyNode hierarchy) { return hierarchy.Parent == null ? null : new Lazy<ISolutionExplorerNode>(() => NodeFactory.Create(hierarchy.Parent, GetParent(hierarchy.Parent))); }
public SolutionNode(VsSolutionHierarchyNode hierarchyNode, ISolutionExplorerNodeFactory nodeFactory) : base(SolutionExplorerNodeKind.Solution, hierarchyNode, null, nodeFactory) { }
public bool CanCreateFrom(VsSolutionHierarchyNode hierarchyNode) { return hierarchyNode.ExtenderObject is VSLangProj.Reference; }
public bool CanCreateFrom(VsSolutionHierarchyNode hierarchyNode) { // Can we do something better here? return hierarchyNode.ExtenderObject == null && hierarchyNode.DisplayName == "References"; }
public ReferenceNode(VsSolutionHierarchyNode hierarchyNode, Lazy<ISolutionExplorerNode> parentNode, ISolutionExplorerNodeFactory nodeFactory) : base(SolutionExplorerNodeKind.Reference, hierarchyNode, parentNode, nodeFactory) { m_dteReference = new Lazy<VSLangProj.Reference>(() => (VSLangProj.Reference)hierarchyNode.ExtenderObject); }
public FolderNode(VsSolutionHierarchyNode hierarchyNode, Lazy<ISolutionExplorerNode> parentNode, ISolutionExplorerNodeFactory nodeFactory) : base(SolutionExplorerNodeKind.Folder, hierarchyNode, parentNode, nodeFactory) { m_dteItem = new Lazy<EnvDTE.ProjectItem>(() => (EnvDTE.ProjectItem)hierarchyNode.ExtenderObject); }
public bool CanCreateFrom(VsSolutionHierarchyNode hierarchyNode) { EnvDTE.ProjectItem projectItem = hierarchyNode.ExtenderObject as EnvDTE.ProjectItem; return projectItem != null && projectItem.Kind == EnvDTE.Constants.vsProjectItemKindPhysicalFolder; }
public ISolutionExplorerNode Create(VsSolutionHierarchyNode hierarchy, Lazy<ISolutionExplorerNode> parent) { return m_factories.FirstOrDefault(factory => factory.CanCreateFrom(hierarchy))?.Create(hierarchy, parent); }
public bool CanCreateFrom(VsSolutionHierarchyNode hierarchyNode) { return hierarchyNode.VsHierarchy is IVsSolution; }
public ItemNode(VsSolutionHierarchyNode hierarchyNode, Lazy<ISolutionExplorerNode> parentNode, ISolutionExplorerNodeFactory nodeFactory) : base(SolutionExplorerNodeKind.Item, hierarchyNode, parentNode, nodeFactory) { m_dteProjectItem = new Lazy<EnvDTE.ProjectItem>(() => (EnvDTE.ProjectItem)hierarchyNode.ExtenderObject); Properties = new ItemProperties(this); }
public bool CanCreateFrom(VsSolutionHierarchyNode hierarchyNode) { return m_factories.Any(factory => factory.CanCreateFrom(hierarchyNode)); }
public bool CanCreateFrom(VsSolutionHierarchyNode hierarchyNode) { var project = hierarchyNode.ExtenderObject as EnvDTE.Project; return project != null && project.Object is EnvDTE80.SolutionFolder; }
public ReferencesFolderNode(VsSolutionHierarchyNode hierarchyNode, Lazy<ISolutionExplorerNode> parentNode, ISolutionExplorerNodeFactory nodeFactory) : base(SolutionExplorerNodeKind.ReferencesFolder, hierarchyNode, parentNode, nodeFactory) { m_dteReferences = new Lazy<VSLangProj.References>(() => ((VSLangProj.VSProject)((EnvDTE.Project)hierarchyNode.VsHierarchy.GetProperty<object>(Microsoft.VisualStudio.Shell.Interop.__VSHPROPID.VSHPROPID_ExtObject, VSConstants.VSITEMID_ROOT)).Object).References); }
protected virtual ISolutionExplorerNode CreateChildNode(VsSolutionHierarchyNode hierarchy) { return NodeFactory.Create(hierarchy, new Lazy<ISolutionExplorerNode>(() => this)); }
public ISolutionExplorerNode Create(VsSolutionHierarchyNode hierarchy, Lazy<ISolutionExplorerNode> parent) { return CanCreateFrom(hierarchy) ? new FolderNode(hierarchy, parent, m_nodeFactory.Value) : null; }
public SolutionFolderNode(VsSolutionHierarchyNode hierarchyNode, Lazy<ISolutionExplorerNode> parent, ISolutionExplorerNodeFactory nodeFactory) : base(SolutionExplorerNodeKind.SolutionFolder, hierarchyNode, parent, nodeFactory) { m_dteSolutionFolder = new Lazy<EnvDTE80.SolutionFolder>(() => (EnvDTE80.SolutionFolder)((EnvDTE.Project)hierarchyNode.ExtenderObject).Object); }