示例#1
0
        private static IEnumerable <ProjectItem> GetAndRebuildCache(
            IVsSolution solution,
            DTE dte)
        {
            var sdmapProjects = new List <string>();

            foreach (var project in GetCSharpProjects(solution))
            {
                var items = GetAllProjectItems(project.ProjectItems)
                            .AsParallel()
                            .Where(x => x.FileCount == 1)
                            .Where(x => x.FileNames[0].EndsWith(".sdmap"));

                var hasSdmap = false;
                foreach (var item in items)
                {
                    hasSdmap = true;
                    yield return(item);
                }

                if (hasSdmap)
                {
                    sdmapProjects.Add(project.UniqueName);
                }
            }

            // rebuild cache
            SdmapProjectCacheManager.Cache(dte, sdmapProjects);
        }
示例#2
0
        public static IEnumerable <ProjectItem> GetSolutionAllSdmapFiles(
            IServiceProvider serviceProvider)
        {
            var dte      = (DTE)serviceProvider.GetService(typeof(DTE));
            var solution = (IVsSolution)serviceProvider.GetService(typeof(IVsSolution));

            return(SdmapProjectCacheManager.Exists(dte) ?
                   GetFromCacheProjects(solution, dte) :
                   GetAndRebuildCache(solution, dte));
        }
示例#3
0
        private static IEnumerable <ProjectItem> GetFromCacheProjects(
            IVsSolution solution,
            DTE dte)
        {
            var sdmapProjectNames = SdmapProjectCacheManager.GetSdmapProjects(dte);

            return(GetCSharpProjects(solution)
                   .Where(x => sdmapProjectNames.Contains(x.UniqueName))
                   .AsParallel()
                   .Select(x => x.ProjectItems)
                   .SelectMany(x => GetAllProjectItems(x))
                   .Where(x => x.FileCount == 1)
                   .Where(x => x.FileNames[0].EndsWith(".sdmap")));
        }