/// <summary> /// Get a collection of HllFileInfo objects matching the given filterset. /// The collection is a Dictionary. The key of each item is the file /// name (without the directory) and the value of each item is /// the corresponding HllFileInfo object. /// /// This is so that UI lists can use bare filenames as keys /// to the associated HllFileInfo objects. /// /// </summary> /// <param name="fs"></param> /// <returns></returns> internal Dictionary <string, HllFileInfo> FilesMatchingFilter(FilterSet fs) { Dictionary <string, HllFileInfo> retDict = new Dictionary <string, HllFileInfo>(); foreach (HllFileInfo hfi in this.MatchingHFis(fs)) { retDict[hfi.BareName] = hfi; } return(retDict); }
/// <summary> /// Get list of full filespecs of /// files matching the given filterset. /// </summary> /// <param name="fs"></param> /// <returns></returns> public List <string> FilePathsMatchingFilter(FilterSet fs) { List <string> retList = new List <string>(); foreach (HllFileInfo item in this.MatchingHFis(fs)) { if (File.Exists(item.FullPath)) { retList.Add(item.FullPath); } } return(retList); }
/// <summary> /// Return list of HllFileInfo objects matching /// the given filterset. /// /// </summary> /// <param name="fs"></param> /// <returns></returns> private List <HllFileInfo> MatchingHFis(FilterSet fs) { List <HllFileInfo> retList = new List <HllFileInfo>(); foreach (HllFileInfo hfi in RegularHllFiles) { if (PassesFilter(hfi, fs)) { retList.Add(hfi); } } if (fs.IncludeBackupsFilter) { foreach (HllFileInfo hfi in BackupHllFiles) { if (PassesFilter(hfi, fs)) { retList.Add(hfi); } } } return(retList); }
/// <summary> /// The UI allows users to select which files to see in the list. Filtering /// is possible by year, donor, and file type, and users can also choose /// whether or not to display backup files. /// </summary> /// <param name="fullpath"></param> /// <returns></returns> private bool PassesFilter(HllFileInfo hfi, FilterSet filterset) { if (!hfi.IsValidHLL) { return(false); } if (hfi.Year != this.filterset.YearFilter) { return(false); } if (!this.filterset.TypeFIlter.Matches(hfi.Type)) { return(false); } if (hfi.HasNoDonor) { return(true); } else { return(DonorMatches(hfi, filterset.DonorFilter)); } }