public void validate_write_text_files_from_file_in_resources() { var testDictionary = SpectralDatabase.GetDefaultDatabaseFromFileInResources(); SpectralDatabase.WriteDatabaseToFiles(testDictionary); Assert.IsTrue(FileIO.FileExists("absorber-Fat.txt")); Assert.IsTrue(FileIO.FileExists("absorber-H2O.txt")); Assert.IsTrue(FileIO.FileExists("absorber-Hb.txt")); Assert.IsTrue(FileIO.FileExists("absorber-HbO2.txt")); Assert.IsTrue(FileIO.FileExists("absorber-Melanin.txt")); Assert.IsTrue(FileIO.FileExists("absorber-Nigrosin.txt")); }
static void Main(string[] args) { var skipImport = false; string[] filenames = null; string path = null; string outname = null; string outpath = null; args.Process(() => { logger.Info("\nSpectral Data Import\n"); logger.Info("For more information type import.exe help"); logger.Info("For help on a specific topic type import.exe help=<topicname>\n"); }, new CommandLine.Switch("help", val => { var helpTopic = val.FirstOrDefault(); ShowHelp(helpTopic); skipImport = true; }), new CommandLine.Switch("@/help", val => { var helpTopic = val.FirstOrDefault(); ShowHelp(helpTopic); skipImport = true; }), new CommandLine.Switch("generatefiles", val => { logger.Info(() => "Generating spectral data files..."); try { var testDictionary = Vts.SpectralMapping.SpectralDatabase.GetDefaultDatabaseFromFileInResources(); SpectralDatabase.WriteDatabaseToFiles(testDictionary); } catch (Exception e) { logger.Info("**** An error occurred while generating the import files ****"); logger.Info("Detailed error: " + e.Message); } skipImport = true; }), new CommandLine.Switch("filename", val => { filenames = new[] { val.FirstOrDefault() }; logger.Info(() => "import files specified as: " + filenames[0]); }), new CommandLine.Switch("filenames", val => { filenames = val.ToArray(); var message = "import files specified as: "; if (filenames.Length > 0) { message = message + filenames.First(); for (int i = 1; i < filenames.Count(); i++) { message = message + ", " + filenames[i]; } } logger.Info(() => message); }), new CommandLine.Switch("path", val => { path = val.FirstOrDefault(); logger.Info(() => "import path specified as " + path); }), new CommandLine.Switch("outname", val => { outname = val.FirstOrDefault(); logger.Info(() => "outname specified as " + outname); }), new CommandLine.Switch("outpath", val => { outpath = val.FirstOrDefault(); logger.Info(() => "outpath specified as " + outpath); })); if (skipImport) { return; } var chromophoreDictionary = SpectralImporter.ImportSpectraFromFile(filenames, path); chromophoreDictionary.WriteToJson(Path.Combine(outpath ?? "", outname ?? "SpectralDictionary.txt")); }