private async Task <object> ProcessData(string inputPath) { Console.WriteLine($"Reading data from {inputPath}"); await using var fileStream = File.OpenRead(inputPath); var totalLineCount = 0; var validLineCount = 0; IDataProcessor dataProcessor = null; await foreach (var dataLine in _fileReader.Read(fileStream, 0)) { if (totalLineCount == 0) { dataProcessor = _dataProcessorFactory.Create(dataLine); } else { if (dataProcessor.ProcessLine(dataLine)) { validLineCount++; } } totalLineCount++; } Console.WriteLine($"Finished reading data - {totalLineCount} total lines; {validLineCount} valid lines"); return(dataProcessor.GetSummary()); }