/// <summary> /// Gets the list of files specified by the hierarchy (IVsSccProject2 or IVsHierarchy) /// </summary> /// <param name="hierarchy"></param> /// <param name="id"></param> /// <param name="depth"></param> /// <returns></returns> /// <remarks>The list might contain duplicates if files are included more than once</remarks> public IEnumerable <string> GetSccFiles(IVsHierarchy hierarchy, uint id, ProjectWalkDepth depth, IDictionary <string, uint> map) { ThreadHelper.ThrowIfNotOnUIThread(); // Note: This command is not cached like the other commands on this object! if (hierarchy == null) { throw new ArgumentNullException("hierarchy"); } SelectionItem si = new SelectionItem(hierarchy, id); string[] files; if (!SelectionUtils.GetSccFiles(si, out files, depth >= ProjectWalkDepth.SpecialFiles, IncludeNoScc(depth), map)) { yield break; } foreach (string file in files) { yield return(SvnTools.GetNormalizedFullPath(file)); } if (depth > ProjectWalkDepth.SpecialFiles) { Dictionary <SelectionItem, SelectionItem> previous = new Dictionary <SelectionItem, SelectionItem>(); previous.Add(si, si); foreach (SelectionItem item in GetDescendants(si, previous, depth)) { if (!SelectionUtils.GetSccFiles(item, out files, depth >= ProjectWalkDepth.SpecialFiles, depth != ProjectWalkDepth.AllDescendantsInHierarchy, map)) { continue; } foreach (string file in files) { yield return(SvnTools.GetNormalizedFullPath(file)); } } } }
/// <summary> /// Gets the selected files; yielding for each result to allow delay loading /// </summary> /// <param name="recursive"></param> /// <returns></returns> IEnumerable <string> InternalGetSelectedFiles(bool recursive) { HybridCollection <string> foundFiles = new HybridCollection <string>(StringComparer.OrdinalIgnoreCase); foreach (SelectionItem i in GetSelectedItems(recursive)) { string[] files; if (SelectionUtils.GetSccFiles(i, out files, true, true, null)) { foreach (string file in files) { if (!foundFiles.Contains(file)) { foundFiles.Add(file); yield return(file); } } } } }
protected IEnumerable <SccProject> InternalGetOwnerProjects() { Hashtable ht = new Hashtable(); bool searchedProjectMapper = false; IProjectFileMapper projectMapper = null; foreach (SelectionItem si in GetSelectedItems(false)) { if (ht.Contains(si.Hierarchy)) { continue; } ht.Add(si.Hierarchy, si); if (si.SccProject != null) { yield return(new SccProject(null, si.SccProject)); continue; } else if (si.Hierarchy is IVsSccVirtualFolders) { continue; // Skip URL WebApplications fast } string[] files; // No need to fetch special files as we only want projects! if (!SelectionUtils.GetSccFiles(si, out files, false, false, null) || files.Length == 0) { continue; // No files selected } if (projectMapper == null && !searchedProjectMapper) { searchedProjectMapper = true; projectMapper = GetService <IProjectFileMapper>(); } if (projectMapper != null) { foreach (string file in files) { foreach (SccProject project in projectMapper.GetAllProjectsContaining(file)) { if (project.RawHandle != null) { if (ht.Contains(project.RawHandle)) { continue; } ht.Add(project.RawHandle, si); yield return(project); } else if (!ht.Contains(project)) { ht.Add(project, si); yield return(project); } } } } } }