private void ProcessAsDirectory(string sourcePath, string optionName, OptionsParser.ResultType resultType) { if (!Directory.Exists(sourcePath)) { throw new ArgumentException(string.Format("{0} directory `{1}` cannot be found", optionName, sourcePath)); } var fileNames = GetAllFileNames(sourcePath).ToArray(); if (!fileNames.Any()) { throw new ArgumentException(string.Format("{0} directory `{1}` doesn't contain any {2} files.", optionName, sourcePath, FileType)); } switch (resultType) { case OptionsParser.ResultType.Test: ResultDirectoryPaths.Add(sourcePath); break; case OptionsParser.ResultType.Baseline: foreach (var filename in fileNames) { BaselineFilePaths.Add(filename); } break; default: throw new InvalidEnumArgumentException(resultType.ToString()); } }
private void ProcessAsXmlDirectory(string xmlSourcePath, string optionName, OptionsParser.ResultType resultType) { if (!Directory.Exists(xmlSourcePath)) { throw new ArgumentException(string.Format("{0} directory `{1}` cannot be found", optionName, xmlSourcePath)); } var xmlFileNames = GetAllXmlFileNames(xmlSourcePath).ToArray(); if (!xmlFileNames.Any()) { throw new ArgumentException(string.Format("{0} directory `{1}` doesn't contain any .xml files.", optionName, xmlSourcePath)); } switch (resultType) { case OptionsParser.ResultType.Test: ResultXmlDirectoryPaths.Add(xmlSourcePath); break; case OptionsParser.ResultType.Baseline: BaselineXmlDirectoryPaths.Add(xmlSourcePath); break; default: throw new InvalidEnumArgumentException(resultType.ToString()); } }
private void ProcessAsXmlFile(string xmlSourcePath, string optionName, OptionsParser.ResultType resultType) { if (!File.Exists(xmlSourcePath)) { throw new ArgumentException(string.Format("{0} file `{1}` cannot be found", optionName, xmlSourcePath)); } switch (resultType) { case OptionsParser.ResultType.Test: ResultXmlFilePaths.Add(xmlSourcePath); break; case OptionsParser.ResultType.Baseline: BaselineXmlFilePaths.Add(xmlSourcePath); break; default: throw new InvalidEnumArgumentException(resultType.ToString()); } }