public void ProcessDirectory(BundleContext context, string directoryVirtualPath, VirtualDirectory dirInfo, List <BundleFile> files) { IEnumerable <VirtualFile> directoryFiles; Regex regEx; switch (PatternType) { // We used to be able to just call DirectoryInfo.GetFiles, // now we have to add support for * and {version} syntax on top of VPP case PatternType.Version: regEx = PatternHelper.BuildRegex(SearchPattern); directoryFiles = dirInfo.Files.Cast <VirtualFile>().Where(file => regEx.IsMatch(file.Name)); break; case PatternType.All: directoryFiles = dirInfo.Files.Cast <VirtualFile>(); break; case PatternType.Exact: directoryFiles = dirInfo.Files.Cast <VirtualFile>().Where(file => String.Equals(file.Name, SearchPattern, StringComparison.OrdinalIgnoreCase)); break; case PatternType.Suffix: case PatternType.Prefix: default: regEx = PatternHelper.BuildWildcardRegex(SearchPattern); directoryFiles = dirInfo.Files.Cast <VirtualFile>().Where(file => regEx.IsMatch(file.Name)); break; } // Sort the directory files so we get deterministic order directoryFiles = directoryFiles.OrderBy(file => file, VirtualFileComparer.Instance); List <BundleFile> filterList = new List <BundleFile>(); foreach (VirtualFile file in directoryFiles) { filterList.Add(new BundleFile(System.IO.Path.Combine(directoryVirtualPath, file.Name), file, Transforms)); } files.AddRange(context.BundleCollection.DirectoryFilter.FilterIgnoredFiles(context, filterList)); // Need to recurse on subdirectories if requested if (SearchSubdirectories) { foreach (VirtualDirectory subDir in dirInfo.Directories) { ProcessDirectory(context, System.IO.Path.Combine(directoryVirtualPath, subDir.Name), subDir, files); } } }
public VersionMatch(string pattern, OptimizationMode mode) : base(pattern, mode) { RegEx = PatternHelper.BuildRegex(Pattern); }