public void CanResolveDirectory() { var directoryEnumerator = new StubDirectoryEnumerator(); var fileResolver = new DirectoryResolver(directoryEnumerator); var files = fileResolver.TryResolve(@"C:\test\").ToList(); Assert.AreEqual(@"C:\test\file1.js", files[0]); Assert.AreEqual(@"C:\test\file2.js", files[1]); Assert.AreEqual(@"C:\test\file3.js", files[2]); Assert.AreEqual(@"C:\test\file4.js", files[3]); Assert.AreEqual(@"C:\test\file5.js", files[4]); }
string get_the_best_match_for_the_packaged_file_name(string filename) { var directoryResolver = new DirectoryResolver(); var matchingFiles = directoryResolver.TryResolve(filename); //string[] matchingFiles = Directory.GetFiles(directory, filename, SearchOption.TopDirectoryOnly);) if (matchingFiles == null || matchingFiles.Count() == 0) { throw new FileNotFoundException("Could not find Packaged bundle matching filename: \"" + filename + "\""); } return select_the_most_recent_matching_file(matchingFiles); }
public bool PackagedFileNameExists(string file) { var directoryResolver = new DirectoryResolver(); bool exists = false; string directory = Path.GetDirectoryName(file); string filename = Path.GetFileName(file).Replace("#", "*"); var matchingFiles = directoryResolver.TryResolve(Path.Combine(directory,filename)); //string[] matchingFiles = Directory.GetFiles(directory, filename, SearchOption.TopDirectoryOnly); if (matchingFiles != null && matchingFiles.Count() > 0) { exists = true; } return exists; }