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);
        }
Esempio n. 3
0
        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");
            }
        }
Esempio n. 4
0
 public PdfFileParser(FileParserConfig config) : base(config)
 {
 }
Esempio n. 5
0
 public DocxFileParser(FileParserConfig config) : base(config)
 {
 }
Esempio n. 6
0
 public HtmlFileParser(FileParserConfig config) : base(config)
 {
 }
Esempio n. 7
0
 public UniversalFileParser(FileParserConfig config)
 {
     mConfig = config;
 }
Esempio n. 8
0
 public TextFileParser(FileParserConfig config) : base(config)
 {
     Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
 }
Esempio n. 9
0
 public BaseParser(FileParserConfig config)
 {
     mConfig = config;
 }
Esempio n. 10
0
 public OfficeParser(FileParserConfig config) : base(config)
 {
 }