/// <summary> /// Writes the current csv record to the stream and clears its content /// </summary> public void Write() { if (_wasPreviousWrite) { _csvWriter.WriteLine(); } _csvWriter.WriteValues(_csvValues); _wasPreviousWrite = true; Array.Fill(_csvValues, null); }
/// <summary> /// Writes the csv dictionary to a CSV target /// </summary> /// <param name="csvWriter">A <see cref="CsvWriter"/></param> /// <returns>Number of key/value pairs written</returns> public int Store(CsvWriter csvWriter) { if (csvWriter == null) { throw new ArgumentNullException(nameof(csvWriter)); } var c = 0; var wasPreviousWrite = false; foreach (var keyValuePair in _keyValuePairs) { if (wasPreviousWrite) { csvWriter.WriteLine(); } wasPreviousWrite = true; csvWriter.WriteValues(keyValuePair.Key, keyValuePair.Value); c++; } return(c); }
/// <summary> /// Writes a list of values to the CSV streem /// </summary> /// <param name="csvWriter">The <see cref="CsvWriter"/></param> /// <param name="values">The list of values to be written.</param> public static void WriteValues(this CsvWriter csvWriter, params string[] values) { csvWriter.WriteValues((IEnumerable <string>)values); }
/// <summary> /// Writes a list of values to the CSV streem and closes the current row within the CSV stream. /// </summary> /// <param name="csvWriter">The <see cref="CsvWriter"/></param> /// <param name="values">The list of values to be written.</param> public static void WriteLineValues(this CsvWriter csvWriter, IEnumerable <string> values) { csvWriter.WriteValues(values); csvWriter.WriteLine(); }