/// <summary> /// Converts a list of string values to a CSV text line /// </summary> /// <param name="csvLineWriter">The <see cref="CsvLineBuilder"/></param> /// <param name="values">List of string values</param> /// <returns> /// A CSV formated text line /// </returns> public static string Write(this CsvLineBuilder csvLineWriter, IEnumerable <string> values) { if (values == null) { throw new ArgumentNullException(nameof(values)); } csvLineWriter.Clear(); foreach (string value in values) { csvLineWriter.Append(value); } return(csvLineWriter.ToString()); }
/// <summary> /// Reads all csv records out of the stream and gives back an enumerator of newly encoded csv strings. /// This method can be used as a line by line syntax checker. /// </summary> /// <param name="csvReader">The <see cref="CsvReader"/></param> /// <returns> /// An async enumerator of newly encoded csv strings /// </returns> public static async IAsyncEnumerable <string> ReadAllLinesAsync(this CsvReader csvReader) { var csvLineBuilder = new CsvLineBuilder() { Configuration = csvReader.Configuration }; while (await csvReader.ReadLineAsync((i, s) => { csvLineBuilder.Append(s); }) > 0) { yield return(csvLineBuilder.ToString()); csvLineBuilder.Clear(); } }