static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("Path argument is missing. Please pass a path argument."); Environment.ExitCode = 1; return; } var path = args[0]; if (!File.Exists(path)) { // Note: FileParser is already validating the file but this is a better place. Console.WriteLine($"File '{path}' not found"); Environment.ExitCode = 1; return; } var config = new FileParserConfig { Delimiter = ',', TargetField = 3, ExpectedFieldCount = 5 }; var printer = new ConsolePrinter(); var fileParser = new FileParser(printer, config); fileParser.Parse(path); }
public void Initialize() { _testFilesFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); _testFilesFolder = Path.Combine(_testFilesFolder, "TestFiles"); _printer = new FakePrinter(TestContext); var config = new FileParserConfig { Delimiter = ',', TargetField = 3, ExpectedFieldCount = 5 }; _target = new FileParser(_printer, config); }
public static IFileParser GetParser(string mimeType, FileParserConfig config) { switch (mimeType) { case "text/html": return(new HtmlFileParser(config)); case "text/plain": return(new TextFileParser(config)); case "application/pdf": return(new PdfFileParser(config)); case "application/vnd.openxmlformats-officedocument.wordprocessingml.document": return(new DocxFileParser(config)); case "application/vnd.openxmlformats-officedocument.presentationml.presentation": return(new PptxFileParser(config)); default: throw new NotSupportedException(mimeType + " not supported"); } }
public PdfFileParser(FileParserConfig config) : base(config) { }
public DocxFileParser(FileParserConfig config) : base(config) { }
public HtmlFileParser(FileParserConfig config) : base(config) { }
public UniversalFileParser(FileParserConfig config) { mConfig = config; }
public TextFileParser(FileParserConfig config) : base(config) { Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); }
public BaseParser(FileParserConfig config) { mConfig = config; }
public OfficeParser(FileParserConfig config) : base(config) { }