VsHierarchy.cs :  » Development » devAdvantage » AnticipatingMinds » VisualStudioServices » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Development » devAdvantage 
devAdvantage » AnticipatingMinds » VisualStudioServices » VsHierarchy.cs
using System;
using System.Collections;
using System.Diagnostics;
using System.Runtime.InteropServices;
//using Microsoft.VisualStudio.OLE.Interop;
using Microsoft.VisualStudio.Shell.Interop;

namespace AnticipatingMinds.VisualStudioServices{
  /// <summary>
  /// Summary description for VsHierarchy.
  /// </summary>
  public class VsHierarchy
  {
    public const uint VSITEMID_NIL = 0xffffffff;
    public const uint VSITEMID_ROOT = 0xfffffffe;
    public const uint VSITEMID_SELECTION = 0xfffffffd;

    [Flags]
    public enum VSEHI // VS Enum Hierarchy Items flags
    {
      VSEHI_Leaf              = 0x00000001,  // return leaf nodes (nonexpandable)
      VSEHI_Branch            = 0x00000002,  // return branch nodes (expandable)
      VSEHI_Nest              = 0x00000004,  // visit nested hierarchies
      VSEHI_AllowSideEffects  = 0x00000008,  // recurse into that return true for VSHPROPID_HasEnumerationSideEffects (requires VSEHI_NEST)
      VSEHI_DataConn          = 0x00000008,  // OBSOLETE. use VSEHI_AllowSideEffects instead
      VSEHI_OmitHier          = 0x00010000   // Don't fill pHier member of VSITEMSELECTION (incompatible with VSEHI_Nest)
    }

    public VsHierarchy(IVsHierarchy vsHierarchy,IServiceProvider site)
    {
      this.vsHierarchy = vsHierarchy;
      this.site = site;
    }

    public VSITEMSELECTION[] GetItems(VSEHI itemTypes)
    {
      ArrayList items = new ArrayList();
      IEnumHierarchyItems enumItems;
      GetHierarchyItemsEnumFactory().EnumHierarchyItems(vsHierarchy,(uint)itemTypes,VSITEMID_ROOT,out enumItems);
      VSITEMSELECTION[] itemSelection = new VSITEMSELECTION[128];
      uint fetchedItems = 0;
      enumItems.Next((uint)itemSelection.Length,itemSelection,out fetchedItems);
      while(fetchedItems != 0)
      {
        for(int i = 0; i < fetchedItems; i++)
          items.Add(itemSelection[i]);
        
        //Did we get all of them or just some?
        if(fetchedItems == itemSelection.Length)
          enumItems.Next((uint)itemSelection.Length,itemSelection,out fetchedItems);
        else
          fetchedItems = 0;
      }
      return items.ToArray(typeof(VSITEMSELECTION)) as VSITEMSELECTION[];
    }

    public IVsEnumHierarchyItemsFactory GetHierarchyItemsEnumFactory()
    {
      return site.GetService(typeof(IVsEnumHierarchyItemsFactory)) as IVsEnumHierarchyItemsFactory;
    }

    public IServiceProvider Site
    {
      get
      {
        return site;
      }
    }

    private IServiceProvider site;
    private Guid typeGuid = Guid.Empty;
    private IVsHierarchy vsHierarchy;

    public static Guid IID_IVsHierarchy = new Guid("{59B2D1D0-5DB0-4f9f-9609-13F0168516D6}");
    public static Guid IID_IVsUIHierarchy = new Guid("{E82609EA-5169-47f4-91D0-6957272CBE9F}");

    /// <summary>Physical file on disk or web (IVsProject::GetMkDocument returns a file path).</summary>
    public static readonly Guid GUID_ItemType_PhysicalFile = new Guid("{6bb5f8ee-4483-11d3-8bcf-00c04f8ec28c}");
    /// <summary>Physical folder on disk or web (IVsProject::GetMkDocument returns a directory path).</summary>
    public static readonly Guid GUID_ItemType_PhysicalFolder = new Guid("{6bb5f8ef-4483-11d3-8bcf-00c04f8ec28c}");
    /// <summary>Non-physical folder (folder is logical and not a physical file system directory).</summary>
    public static readonly Guid GUID_ItemType_VirtualFolder = new Guid("{6bb5f8f0-4483-11d3-8bcf-00c04f8ec28c}");
    /// <summary>A nested hierarchy project.</summary>
    public static readonly Guid GUID_ItemType_SubProject = new Guid("{EA6618E8-6E24-4528-94BE-6889FE16485C}");
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.