当前位置: 首页>>代码示例>>C#>>正文


C# IVsSolution.GetProjectEnum方法代码示例

本文整理汇总了C#中IVsSolution.GetProjectEnum方法的典型用法代码示例。如果您正苦于以下问题:C# IVsSolution.GetProjectEnum方法的具体用法?C# IVsSolution.GetProjectEnum怎么用?C# IVsSolution.GetProjectEnum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IVsSolution的用法示例。


在下文中一共展示了IVsSolution.GetProjectEnum方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetProjectsInSolution

        internal static IEnumerable<IVsHierarchy> GetProjectsInSolution(IVsSolution solution)
        {
            if (solution == null)
            {
                throw new ArgumentNullException("solution");
            }

            IEnumHierarchies penum = null;
            var nullGuid = Guid.Empty;
            var hr = solution.GetProjectEnum((uint)__VSENUMPROJFLAGS.EPF_ALLPROJECTS, ref nullGuid, out penum);
            if (ErrorHandler.Succeeded(hr)
                && (penum != null))
            {
                uint fetched = 0;
                var rgelt = new IVsHierarchy[1];
                while (penum.Next(1, rgelt, out fetched) == 0
                       && fetched == 1)
                {
                    yield return rgelt[0];
                }
            }
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:22,代码来源:BootstrapUtils.cs

示例2: GetProjects

        // Traditional VS traversal via enumeration.
        public static EnvDTE.Project[] GetProjects(IVsSolution solution, string projectKind = null)
        {
            var projects = new List<Project>();

            if (solution == null)
            {
                return projects.ToArray();
            }

            IEnumHierarchies ppEnum;
            Guid tempGuid = Guid.Empty;
            solution.GetProjectEnum((uint)Microsoft.VisualStudio.Shell.Interop.__VSENUMPROJFLAGS.EPF_ALLPROJECTS, ref tempGuid, out ppEnum);
            if (ppEnum != null)
            {
                uint actualResult = 0;
                IVsHierarchy[] nodes = new IVsHierarchy[1];
                while (0 == ppEnum.Next(1, nodes, out actualResult))
                {
                    Object obj;
                    nodes[0].GetProperty((uint)Microsoft.VisualStudio.VSConstants.VSITEMID_ROOT, (int)Microsoft.VisualStudio.Shell.Interop.__VSHPROPID.VSHPROPID_ExtObject, out obj);
                    Project project = obj as Project;
                    if (project != null)
                    {
                        if (string.IsNullOrEmpty(projectKind))
                        {
                            projects.Add(project);
                        }
                        else if (projectKind.Equals(project.Kind, StringComparison.InvariantCultureIgnoreCase))
                        {
                            projects.Add(project);
                        }
                    }
                }
            }
            return projects.ToArray();
        }
开发者ID:MobileEssentials,项目名称:clide,代码行数:37,代码来源:PerformanceSpec.cs

示例3: EnumerateLoadedProjects

 private static IEnumerable<IVsProject> EnumerateLoadedProjects(IVsSolution solution) {
     var guid = new Guid(PythonConstants.ProjectFactoryGuid);
     IEnumHierarchies hierarchies;
     ErrorHandler.ThrowOnFailure((solution.GetProjectEnum(
         (uint)(__VSENUMPROJFLAGS.EPF_MATCHTYPE | __VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION),
         ref guid,
         out hierarchies)));
     IVsHierarchy[] hierarchy = new IVsHierarchy[1];
     uint fetched;
     while (ErrorHandler.Succeeded(hierarchies.Next(1, hierarchy, out fetched)) && fetched == 1) {
         var project = hierarchy[0] as IVsProject;
         if (project != null) {
             yield return project;
         }
     }
 }
开发者ID:omnimark,项目名称:PTVS,代码行数:16,代码来源:TestContainerDiscoverer.cs

示例4: ProjectsInSolution

 public static IEnumerable<IVsProject> ProjectsInSolution(IVsSolution solution)
 {
     IEnumHierarchies enumerator;
     var guid = Guid.Empty;
     solution.GetProjectEnum((uint) __VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION, ref guid, out enumerator);
     var hierarchy = new IVsHierarchy[] {null};
     uint fetched;
     for (enumerator.Reset();
         enumerator.Next(1, hierarchy, out fetched) == VSConstants.S_OK && fetched == 1;
         /*nothing*/)
     {
         yield return (IVsProject) hierarchy[0];
     }
 }
开发者ID:mpartipilo,项目名称:SonarCompanion,代码行数:14,代码来源:VsInteropUtilities.cs

示例5: GetProjectsInSolution

        private static IEnumerable<IVsHierarchy> GetProjectsInSolution(IVsSolution solution)
        {
            if (solution == null) throw new ArgumentNullException("solution");

            IEnumHierarchies enumHierarchies;
            var guid = Guid.Empty;
            solution.GetProjectEnum((uint)__VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION, ref guid, out enumHierarchies);

            // Invalid result?
            if (enumHierarchies == null)
                yield break;

            var hierarchyArray = new IVsHierarchy[1];
            uint hierarchyFetched;

            // Fetch one by one
            while (enumHierarchies.Next(1, hierarchyArray, out hierarchyFetched) == VSConstants.S_OK && hierarchyFetched == 1)
            {
                if (hierarchyArray[0] != null)
                    yield return hierarchyArray[0];
            }
        }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:22,代码来源:VsHelper.cs

示例6: GetProjectAndFileInfoForPath

    private static void GetProjectAndFileInfoForPath(
        string originalPath, IServiceProvider serviceProvider, IVsSolution solution, out IVsHierarchy projectHierarchy,
        out Project project, out uint fileItemId, out bool isDocumentInProject) {
      var guid = Guid.Empty;
      IEnumHierarchies hierarchyEnum = null;
      fileItemId = VSConstants.VSITEMID_NIL;
      projectHierarchy = null;
      isDocumentInProject = false;
      project = null;

      if (solution != null) {
        var hr = solution.GetProjectEnum((uint)__VSENUMPROJFLAGS.EPF_ALLPROJECTS, ref guid, out hierarchyEnum);
        if (NativeMethods.Succeeded(hr) && hierarchyEnum != null) {
          hierarchyEnum.Reset();

          uint numFetched = 1;
          var item = new IVsHierarchy[1];

          hierarchyEnum.Next(1, item, out numFetched);
          while (numFetched == 1) {
            var vsProject = item[0] as IVsProject;
            if (vsProject != null) {
              GetProjectAndFileInfoForPath(
                  vsProject, originalPath, out projectHierarchy, out project, out fileItemId, out isDocumentInProject);
              if (isDocumentInProject) {
                break;
              }
            }
            hierarchyEnum.Next(1, item, out numFetched);
          }
        }
      }

      // didn't find a project, so check the misc files project
      if (project == null) {
        //
        // try not to create the Misc files project externally - in some rare cases it has caused Access violoations in VS (e.g., Dev10 Bug 864725).  
        // So, only create this if we really need it. 
        //
        IVsProject3 miscFilesProject = null;
        if (serviceProvider == null) {
          miscFilesProject = GetMiscellaneousProject();
        } else {
          miscFilesProject = GetMiscellaneousProject(serviceProvider);
        }

        if (miscFilesProject != null) {
          GetProjectAndFileInfoForPath(
              miscFilesProject, originalPath, out projectHierarchy, out project, out fileItemId, out isDocumentInProject);
          if (project == null) {
            projectHierarchy = miscFilesProject as IVsHierarchy;
            if (projectHierarchy != null) {
              project = GetProject(projectHierarchy);
            }
          }
        }
      }
    }
开发者ID:PavelPZ,项目名称:REW,代码行数:58,代码来源:VSHelpers.cs

示例7: EnumerateProjects

 private static IEnumerable<IVsHierarchy> EnumerateProjects(IVsSolution solution)
 {
     Guid empty = Guid.Empty;
     IEnumHierarchies projectsEnum;
     ErrorHandler.ThrowOnFailure(solution.GetProjectEnum((uint)__VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION, ref empty, out projectsEnum));
     IVsHierarchy[] output = new IVsHierarchy[1];
     uint fetched;
     while (ErrorHandler.Succeeded(projectsEnum.Next(1, output, out fetched)) && fetched == 1)
     {
         yield return output[0];
     }
 }
开发者ID:duncanpMS,项目名称:sonarlint-visualstudio,代码行数:12,代码来源:ProjectSystemHelper.cs

示例8: GetProjectsInSolution

        public static IEnumerable<IVsHierarchy> GetProjectsInSolution(IVsSolution solution, __VSENUMPROJFLAGS flags)
        {
            if (solution == null)
                yield break;

            IEnumHierarchies enumHierarchies;
            Guid guid = Guid.Empty;
            solution.GetProjectEnum((uint)flags, ref guid, out enumHierarchies);
            if (enumHierarchies == null)
                yield break;

            IVsHierarchy[] hierarchy = new IVsHierarchy[1];
            uint fetched;
            while (enumHierarchies.Next(1, hierarchy, out fetched) == VSConstants.S_OK && fetched == 1)
            {
                if (hierarchy.Length > 0 && hierarchy[0] != null)
                    yield return hierarchy[0];
            }
        }
开发者ID:japj,项目名称:ExtensibilityTools,代码行数:19,代码来源:ProjectHelpers.cs


注:本文中的IVsSolution.GetProjectEnum方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。