public override FileDescriptor[] GetFiles(string structureName, string searchPattern, Selector[] selectors) { // Collect all files in given directories conforming to search pattern and selectors. List <FoundationDiskFileDescriptor> list; string cacheKey = BuildCacheKey(selectors, ModulesDirectoryPath, structureName, searchPattern); lock (_cache) { if (_cache.ContainsKey(cacheKey)) { list = _cache[cacheKey]; } else { list = new List <FoundationDiskFileDescriptor>(); Dictionary <string, int> moduleOrderByName = new Dictionary <string, int>(); int index = 0; foreach (string name in FileResolver.GetOrderedModules()) { moduleOrderByName.Add(name.ToUpperInvariant(), index++); } if (Directory.Exists(ModulesDirectoryPath)) { foreach (string modulePath in Directory.GetDirectories(ModulesDirectoryPath)) { string searchPath = string.Concat(modulePath, Path.DirectorySeparatorChar, SearchDirectoryName, Path.DirectorySeparatorChar, structureName); if (Directory.Exists(searchPath)) { foreach (string filePath in Directory.GetFiles(searchPath, searchPattern, _searchSubdirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly)) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(filePath); if (selectors == null || ValidateFileName(fileNameWithoutExtension, selectors)) { string moduleName = Path.GetFileName(modulePath); var descriptor = new FoundationDiskFileDescriptor(this); descriptor.ModuleName = moduleName; descriptor.FileNameWithoutExtension = fileNameWithoutExtension; descriptor.FilePath = filePath; int moduleOrder = int.MaxValue; string moduleKey = moduleName.ToUpperInvariant(); if (moduleOrderByName.ContainsKey(moduleKey)) { moduleOrder = moduleOrderByName[moduleKey]; } descriptor.ModuleOrder = moduleOrder; descriptor.FileCreationTimeTicks = File.GetCreationTime(filePath).Ticks; list.Add(descriptor); } } } } } list.Sort(FoundationDiskFileDescriptor.Compare); _cache.Add(cacheKey, list); } } return(list.ToArray()); }