VsProject.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 » VsProject.cs
using System;
using System.Diagnostics;
using System.Collections;
using System.Collections.Specialized;
using Microsoft.VisualStudio.Shell.Interop;

namespace AnticipatingMinds.VisualStudioServices{
  /// <summary>
  /// Summary description for VsProject.
  /// </summary>
  public class VsProject : VsHierarchy
  {
    public VsProject(IVsProject vsProject,IServiceProvider site):base(vsProject as IVsHierarchy,site)
    {
      this.enumHierarchyItemsFactory = enumHierarchyItemsFactory;
      this.vsProject = vsProject;
    }

    public string FileName
    {
      get
      {
        string fileName;
        vsProject.GetMkDocument(VsHierarchy.VSITEMID_ROOT,out fileName);
        return fileName;
      }
    }

    public VsProject[] GetSubProjects()
    {
      Hashtable projectFileNames = new Hashtable();
      VSITEMSELECTION[] items = GetItems(VSEHI.VSEHI_Branch | VSEHI.VSEHI_Nest);
      foreach(VSITEMSELECTION item in items)
      {
        if(item.itemid == VSITEMID_ROOT && (item.pHier as IVsProject) != null)
        {
          string projectFileName;
          IVsProject project = item.pHier as IVsProject;
          project.GetMkDocument(VSITEMID_ROOT,out projectFileName);
          if(!projectFileNames.Contains(projectFileName))
            projectFileNames[projectFileName] = new VsProject(project,Site);
        }
      }

      VsProject[] projects = new VsProject[projectFileNames.Count];
      projectFileNames.Values.CopyTo(projects,0);
      return projects;
    }

    public StringCollection GetReferences()
    {
      StringCollection projectReferences = new StringCollection();

      VSITEMSELECTION[] items = GetItems(VSEHI.VSEHI_Leaf | VSEHI.VSEHI_Nest);
      IVsHierarchy projectHierarchy = (vsProject as IVsHierarchy);
      foreach(VSITEMSELECTION item in items)
      {
        if(item.itemid != VSITEMID_ROOT)
        {
          object value;
          (vsProject as IVsHierarchy).GetProperty(item.itemid,(int)__VSHPROPID.VSHPROPID_ExtObject,out value);
          VSLangProj.Reference reference = value as VSLangProj.Reference;
          if(reference != null && reference.Path != null && reference.Path.Length != 0)
            projectReferences.Add(reference.Path);
        }
      }
      return projectReferences;
    }

    public StringCollection GetFiles()
    {
      StringCollection projectFiles = new StringCollection();

      VSITEMSELECTION[] items = GetItems(VSEHI.VSEHI_Leaf | VSEHI.VSEHI_Nest);
      IVsHierarchy projectHierarchy = (vsProject as IVsHierarchy);
      foreach(VSITEMSELECTION item in items)
      {
        if(item.itemid != VSITEMID_ROOT)
        {
          Guid typeGuid;
          projectHierarchy.GetGuidProperty(item.itemid,(int)__VSHPROPID.VSHPROPID_TypeGuid,out typeGuid);
          if(typeGuid != GUID_ItemType_PhysicalFile)
            continue;

          object value;
          EnvDTE.ProjectItem projectItem;
          projectHierarchy.GetProperty(item.itemid,(int) __VSHPROPID.VSHPROPID_ExtObject,out value);
          projectItem = value as EnvDTE.ProjectItem;
          if(projectItem.FileCount != 0)
            projectFiles.Add(projectItem.get_FileNames(1));
        }
      }

      return projectFiles;
    }

    public EnvDTE.Project Project
    {
      get
      {
        object value;
        (vsProject as IVsHierarchy).GetProperty(VSITEMID_ROOT,(int)__VSHPROPID.VSHPROPID_ExtObject,out value);
        return value as EnvDTE.Project;
      }
    }

    private IVsProject vsProject;

    private IVsEnumHierarchyItemsFactory enumHierarchyItemsFactory;
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.