public virtual bool Supports(IVsHierarchyItem item) { var extenderObject = item.GetExtenderObject(); var projectItem = extenderObject as EnvDTE.ProjectItem; if (extenderObject == null || projectItem == null) { return(false); } if (extenderObject.GetType().FullName == "Microsoft.VisualStudio.Project.Automation.OAFolderItem") { return(true); } try { // Fails in F# projects. return(projectItem.Kind == EnvDTE.Constants.vsProjectItemKindPhysicalFolder); } catch (Exception) { return(false); } }
public virtual bool Supports(IVsHierarchyItem item) { var project = item.GetExtenderObject() as EnvDTE.Project; return project != null && project.Object is EnvDTE80.SolutionFolder; }
public virtual bool Supports(IVsHierarchyItem item) { var project = item.GetExtenderObject() as EnvDTE.Project; return(project != null && project.Object is EnvDTE80.SolutionFolder); }
public virtual bool Supports(IVsHierarchyItem item) { var result = false; // For performance reasons we're first checking if the // extender object is null which it's expected for // the ReferencesNode if (item.GetExtenderObject() == null && item.Parent?.GetExtenderObject() is EnvDTE.Project) { // Then we first check for the localized Text string result = item.Text == "References" || item.Text == "Referencias"; if (!result) { // Or first if any child is an instance of VSLangProj.Reference // It's important to call .Children to avoid ending up with duplicate // element when Children are still not created // And also we need to use Any because the first item might be // a PackageReference which does not provide an extender object result = asyncManager.Run(async() => { await asyncManager.SwitchToMainThreadAsync(); return(item.Children.Any(x => x.GetExtenderObject() is VSLangProj.Reference)); }); } } return(result); }
bool Supports (IVsHierarchyItem item, out IVsHierarchyItem actualItem) { actualItem = item; if (!item.HierarchyIdentity.IsRoot) return false; // We need the hierarchy fully loaded if it's not yet. if (!item.GetProperty<bool> (__VSPROPID4.VSPROPID_IsSolutionFullyLoaded)) { Guid guid; if (ErrorHandler.Succeeded (item.GetActualHierarchy ().GetGuidProperty ((uint)VSConstants.VSITEMID.Root, (int)__VSHPROPID.VSHPROPID_ProjectIDGuid, out guid)) && // For the solution root item itself, the GUID will be empty. guid != Guid.Empty) { if (ErrorHandler.Succeeded (((IVsSolution4)solution.Value).EnsureProjectIsLoaded (ref guid, (uint)__VSBSLFLAGS.VSBSLFLAGS_None))) actualItem = hierarchyManager.GetHierarchyItem (item.GetActualHierarchy (), item.GetActualItemId ()); } } if (!(actualItem.GetActualHierarchy () is IVsProject)) return false; // Finally, solution folders look like projects, but they are not. // We need to filter them out too. var extenderObject = actualItem.GetExtenderObject(); var dteProject = extenderObject as EnvDTE.Project; if (extenderObject != null && extenderObject.GetType ().FullName == "Microsoft.VisualStudio.Project.Automation.OAProject") return false; if (extenderObject != null && dteProject != null && (dteProject.Object is EnvDTE80.SolutionFolder)) return false; return true; }
/// <summary> /// Initializes a new instance of the <see cref="FolderNode"/> class. /// </summary> /// <param name="hierarchyNode">The underlying hierarchy represented by this node.</param> /// <param name="parentNode">The parent node accessor.</param> /// <param name="nodeFactory">The factory for child nodes.</param> /// <param name="adapter">The adapter service that implements the smart cast <see cref="ITreeNode.As{T}"/>.</param> public FolderNode(IVsHierarchyItem hierarchyNode, ISolutionExplorerNodeFactory nodeFactory, IAdapterService adapter, Lazy <IVsUIHierarchyWindow> solutionExplorer) : base(SolutionNodeKind.Folder, hierarchyNode, nodeFactory, adapter, solutionExplorer) { Folder = new Lazy <ProjectItem>(() => hierarchyNode.GetExtenderObject() as ProjectItem); }
bool Supports(IVsHierarchyItem item, out IVsHierarchyItem actualItem) { actualItem = item; if (!item.HierarchyIdentity.IsRoot) { return(false); } // We need the hierarchy fully loaded if it's not yet. if (!item.GetProperty <bool>(__VSPROPID4.VSPROPID_IsSolutionFullyLoaded)) { // EnsureProjectIsLoaded MUST be executed in the UI/Main thread // Otherwise (if the Supports method is being invoked from a worker thread) duplicate keys might be generated actualItem = asyncManager.Run(async() => { await asyncManager.SwitchToMainThreadAsync(); Guid guid; if (ErrorHandler.Succeeded(item.GetActualHierarchy().GetGuidProperty((uint)VSConstants.VSITEMID.Root, (int)__VSHPROPID.VSHPROPID_ProjectIDGuid, out guid)) && // For the solution root item itself, the GUID will be empty. guid != Guid.Empty) { if (ErrorHandler.Succeeded(((IVsSolution4)solution.GetValue()).EnsureProjectIsLoaded(ref guid, (uint)__VSBSLFLAGS.VSBSLFLAGS_None))) { return(hierarchyManager.GetHierarchyItem(item.GetActualHierarchy(), item.GetActualItemId())); } } return(item); }); } var hierarchy = actualItem.GetActualHierarchy(); if (!(actualItem.GetActualHierarchy() is IVsProject) && !(hierarchy is FlavoredProjectBase)) { return(false); } // Finally, solution folders look like projects, but they are not. // We need to filter them out too. var extenderObject = actualItem.GetExtenderObject(); var dteProject = extenderObject as EnvDTE.Project; if (extenderObject != null && extenderObject.GetType().FullName == "Microsoft.VisualStudio.Project.Automation.OAProject") { return(false); } if (extenderObject != null && dteProject != null && (dteProject.Object is EnvDTE80.SolutionFolder)) { return(false); } return(true); }
/// <summary> /// Initializes a new instance of the <see cref="SolutionFolderNode"/> class. /// </summary> /// <param name="hierarchyNode">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="ITreeNode.As{T}"/>.</param> public SolutionFolderNode( IVsHierarchyItem hierarchyNode, ISolutionExplorerNodeFactory nodeFactory, IAdapterService adapter, JoinableLazy <IVsUIHierarchyWindow> solutionExplorer) : base(SolutionNodeKind.SolutionFolder, hierarchyNode, nodeFactory, adapter, solutionExplorer) { SolutionFolder = new Lazy <SolutionFolder>( () => (SolutionFolder)((Project)hierarchyNode.GetExtenderObject()).Object); }
public virtual bool Supports(IVsHierarchyItem item) { // TODO: why wouldn't something like this work? // // ((VSProject)((Project)hierarchyNode.GetExtenderObject ()).Object).References); // \o/: heuristics, no extender object and "References" display name :S var extObj = item.GetExtenderObject(); // TODO: see if we get the VSProject from VSLangProj and compare to the References property there. return extObj == null && item.Text == "References"; }
IEnumerable <string> GetPropertyNames() { try { return(((ProjectItem)node.GetExtenderObject()) .Properties .Cast <Property> () .Select(prop => prop.Name)); } catch { return(Enumerable.Empty <string> ()); } }
public virtual bool Supports(IVsHierarchyItem item) { // TODO: why wouldn't something like this work? // // ((VSProject)((Project)hierarchyNode.GetExtenderObject ()).Object).References); // \o/: heuristics, no extender object and "References" display name :S var extObj = item.GetExtenderObject(); // TODO: see if we get the VSProject from VSLangProj and compare to the References property there. return(extObj == null && item.Text == "References"); }
/// <summary> /// Initializes a new instance of the <see cref="SolutionItemNode"/> class. /// </summary> /// <param name="hierarchyNode">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="ITreeNode.As{T}"/>.</param> public SolutionItemNode( IVsHierarchyItem hierarchyNode, ISolutionExplorerNodeFactory nodeFactory, IAdapterService adapter, JoinableLazy <IVsUIHierarchyWindow> solutionExplorer) : base(SolutionNodeKind.SolutionItem, hierarchyNode, nodeFactory, adapter, solutionExplorer) { this.nodeFactory = nodeFactory; Item = new Lazy <ProjectItem>(() => (ProjectItem)hierarchyNode.GetExtenderObject()); owningFolder = new Lazy <ISolutionFolderNode>(() => this.nodeFactory.CreateNode(hierarchyNode.GetRoot()) as ISolutionFolderNode); }
public virtual bool Supports(IVsHierarchyItem hierarchy) { if (hierarchy.Parent == null) return false; var ext = hierarchy.GetExtenderObject(); var item = ext as ProjectItem; var project = hierarchy.Parent.GetExtenderObject() as Project; return project != null && item != null && project.Object is EnvDTE80.SolutionFolder; }
public virtual bool Supports(IVsHierarchyItem item) { var extenderObject = item.GetExtenderObject(); var projectItem = extenderObject as EnvDTE.ProjectItem; if (extenderObject == null || projectItem == null) return false; try { // Fails in F# projects. return projectItem.Kind == EnvDTE.Constants.vsProjectItemKindPhysicalFile; } catch (Exception) { return false; } }
public virtual bool Supports(IVsHierarchyItem hierarchy) { if (hierarchy.Parent == null) { return(false); } var ext = hierarchy.GetExtenderObject(); var item = ext as ProjectItem; var project = hierarchy.Parent.GetExtenderObject() as Project; return (project != null && item != null && project.Object is EnvDTE80.SolutionFolder); }
public virtual bool Supports(IVsHierarchyItem item) { var extenderObject = item.GetExtenderObject(); var projectItem = extenderObject as EnvDTE.ProjectItem; if (extenderObject == null || projectItem == null) { return(false); } try { // Fails in F# projects. return(projectItem.Kind == EnvDTE.Constants.vsProjectItemKindPhysicalFile); } catch (Exception) { return(false); } }
bool Supports(IVsHierarchyItem item, out IVsHierarchyItem actualItem) { actualItem = item; if (!item.HierarchyIdentity.IsRoot) { return(false); } // We need the hierarchy fully loaded if it's not yet. if (!item.GetProperty <bool>(__VSPROPID4.VSPROPID_IsSolutionFullyLoaded)) { Guid guid; if (ErrorHandler.Succeeded(item.GetActualHierarchy().GetGuidProperty((uint)VSConstants.VSITEMID.Root, (int)__VSHPROPID.VSHPROPID_ProjectIDGuid, out guid)) && // For the solution root item itself, the GUID will be empty. guid != Guid.Empty) { if (ErrorHandler.Succeeded(((IVsSolution4)solution.Value).EnsureProjectIsLoaded(ref guid, (uint)__VSBSLFLAGS.VSBSLFLAGS_None))) { actualItem = hierarchyManager.GetHierarchyItem(item.GetActualHierarchy(), item.GetActualItemId()); } } } if (!(actualItem.GetActualHierarchy() is IVsProject)) { return(false); } // Finally, solution folders look like projects, but they are not. // We need to filter them out too. var extenderObject = actualItem.GetExtenderObject(); var dteProject = extenderObject as EnvDTE.Project; if (extenderObject != null && extenderObject.GetType().FullName == "Microsoft.VisualStudio.Project.Automation.OAProject") { return(false); } if (extenderObject != null && dteProject != null && (dteProject.Object is EnvDTE80.SolutionFolder)) { return(false); } return(true); }
public virtual bool Supports (IVsHierarchyItem item) { var extenderObject = item.GetExtenderObject(); var projectItem = extenderObject as EnvDTE.ProjectItem; if (extenderObject == null || projectItem == null) return false; if (extenderObject.GetType ().FullName == "Microsoft.VisualStudio.Project.Automation.OAFolderItem") return true; try { // Fails in F# projects. return projectItem.Kind == EnvDTE.Constants.vsProjectItemKindPhysicalFolder; } catch (Exception) { return false; } }
public virtual bool Supports(IVsHierarchyItem item) => item.GetExtenderObject() is VSLangProj.Reference;