private static string ReadInputFile(Configuration configuration) { string input; try { input = PreProcessor.ReadAndProcess(configuration.InputFileName, configuration); } catch (FileNotFoundException ex) { throw new ErrorMessageException(String.Format(md2html.Properties.Resources.InputFileNotFoundErrorMessage, configuration.InputFileName, ex.Message), ex); } return(input); }
public static string ReadAndProcess(string fileName, Configuration configuration) { if (Object.ReferenceEquals(null, fileName) || fileName.Trim().Length == 0) { throw new ArgumentNullException("fileName"); } if (Object.ReferenceEquals(null, configuration)) { throw new ArgumentNullException("configuration"); } PreProcessor processor = new PreProcessor(configuration); IEnumerable <MarkdownSourceLineEntry> lines = MarkdownSourceReader.Read(fileName); IEnumerable <MarkdownSourceLineEntry> processedLines = processor.Process(lines); return(string.Join(Environment.NewLine, (from line in processedLines select line.Line).ToArray())); }