public void Process(string inputFile) { _reader.Open(inputFile, CSVReaderWriter.Mode.Read); string column1, column2; while (_reader.Read(out column1, out column2)) { _mailShot.SendMailShot(column1, column2); } _reader.Close(); }
public void Process(string inputFile) { // Slight better approach. Helps unit testing by mocking CSVReaderWriter dependency. // These methods are made obsolete just to enforce the callers to use refactored approach and can be removed in future. this._csvReaderWriter.Open(inputFile, CSVReaderWriter.Mode.Read); string column1, column2; while (this._csvReaderWriter.Read(out column1, out column2)) { _mailShot.SendMailShot(column1, column2); } this._csvReaderWriter.Close(); }
public void Process(string inputFile) { var reader = new CsvReaderWriter(); reader.Open(inputFile, CSVReaderWriterForAnnotation.Mode.Read); string column1, column2; while (reader.Read(out column1, out column2)) { _mailShot.SendMailShot(column1, column2); } reader.Close(); }
public void Process(string inputFile) { //Updated to instantiate the object in a using statment to ensure Dispose() is called //when code exists the using block using (var reader = new CSVReaderWriter()) { reader.Open(inputFile, CSVReaderWriter.Mode.Read); string column1, column2; while (reader.Read(out column1, out column2)) { _mailShot.SendMailShot(column1, column2); } } }
public void Process(string inputFile) { // using old approach. // These methods are made obsolete just to enforce the callers to use refactored approach and can be removed in future. // CSVReaderWriter dependency can be handled throgh interface rather than directly depending on it, as shown in Process1() method. var reader = new CSVReaderWriter(); reader.Open(inputFile, CSVReaderWriter.Mode.Read); string column1, column2; while (reader.Read(out column1, out column2)) { _mailShot.SendMailShot(column1, column2); } reader.Close(); }
public void Process(string inputFile) { using (var stream = File.OpenText(inputFile)) { var reader = new TSV.TSVReader(stream); var line = reader.ReadLine(); while (line != null) { if (line.Count > 1) //skip invalid lines... { _mailShot.SendMailShot(line[0], line[1]); } line = reader.ReadLine(); } } }
public void Process(string inputFile) { // using new approach this._csvReader.Read <EmailShot>(inputFile).ToList().ForEach(p => _mailShot.SendMailShot(p.Name, p.Address)); }