private void ExtractFileList <T>(HACmdLineFSEntityList <T> aList, SXILElementCategory aCategory, bool aExpandDirectoriesToUnderlyingFiles) where T : HACmdLineFSEntity, new() { foreach (SXILElement element in aCategory) { if (element is SXILElementFile) { SXILElementFile file = (SXILElementFile)element; Trace("[CmdInput] ExtractFileList() - file: " + file); if (!file.Exists) { throw new FileNotFoundException("File not found", file.Name); } // aList.Add(file); } else if (element is SXILElementDirectory) { SXILElementDirectory dir = (SXILElementDirectory)element; Trace("[CmdInput] ExtractFileList() - dir: " + dir); if (!dir.Exists) { throw new DirectoryNotFoundException("Directory not found: " + dir.Name); } // if (aExpandDirectoriesToUnderlyingFiles) { aList.AddRange(dir.Files); } else { aList.Add(dir.Directory); } } } }
private void ExtractOutput(SXILElementCategory aCategory) { // We either output to file or directory - if both are present then bail out FileInfo savedFile = null; DirectoryInfo savedDir = null; // foreach (SXILElement element in aCategory) { if (element is SXILElementFile) { if (savedFile != null) { throw new InvalidDataException("Output file already specified"); } else { SXILElementFile file = (SXILElementFile)element; savedFile = file; } } else if (element is SXILElementDirectory) { if (savedDir != null) { throw new InvalidDataException("Output directory already specified"); } else { SXILElementDirectory dir = (SXILElementDirectory)element; savedDir = dir; } } } // Ensure we have only one type if (savedFile != null && savedDir != null) { throw new InvalidDataException("Output must be EITHER file or directory"); } else if (savedFile != null) { iSinkParams.OutputFile = savedFile; } else if (savedDir != null) { iSinkParams.OutputDirectory = savedDir; } }