Beispiel #1
0
        /// <summary>
        /// Writes a list of custom csv objects directly to the csv stream and opens a new row.
        /// </summary>
        /// <typeparam name="TEntity">The custom csv object type</typeparam>
        /// <param name="csvTableWriter">The <see cref="CsvTableWriter"/></param>
        /// <param name="entities">List of csv custom objects</param>
        public static void WriteAll <TEntity>(this CsvTableWriter csvTableWriter, IEnumerable <TEntity> entities)
        {
            if (entities == null)
            {
                throw new ArgumentNullException(nameof(entities));
            }

            foreach (var entity in entities)
            {
                csvTableWriter.SetValues(entity);
                csvTableWriter.Write();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Writes a list of custom csv objects directly to the csv stream and opens a new row.
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="csvTableWriter">The <see cref="CsvTableWriter"/></param>
        /// <param name="entities">List of csv custom objects</param>
        /// <param name="cancellationToken">Cancellation token</param>
        /// <returns>A task that represents the asynchronous write operation.</returns>
        public static async Task WriteAllAsync <TEntity>(this CsvTableWriter csvTableWriter, IEnumerable <TEntity> entities, CancellationToken cancellationToken = default)
        {
            if (entities == null)
            {
                throw new ArgumentNullException(nameof(entities));
            }

            foreach (var entity in entities)
            {
                cancellationToken.ThrowIfCancellationRequested();

                csvTableWriter.SetValues(entity);
                await csvTableWriter.WriteAsync();
            }
        }
Beispiel #3
0
 /// <summary>
 /// Writes a custom csv object directly to the csv stream and opens a new row.
 /// </summary>
 /// <typeparam name="TEntity">The custom csv object type</typeparam>
 /// <param name="csvTableWriter">The <see cref="CsvTableWriter"/></param>
 /// <param name="entity">The csv custom object</param>
 public static void Write <TEntity>(this CsvTableWriter csvTableWriter, TEntity entity)
 {
     csvTableWriter.SetValues(entity);
     csvTableWriter.Write();
 }
Beispiel #4
0
 /// <summary>
 /// Writes a custom csv object directly to the csv stream and opens a new row.
 /// </summary>
 /// <typeparam name="TEntity">The custom csv object type</typeparam>
 /// <param name="csvTableWriter">The <see cref="CsvTableWriter"/></param>
 /// <param name="entity">The csv object</param>
 /// <returns>A task that represents the asynchronous write operation.</returns>
 public static async Task WriteAsync <TEntity>(this CsvTableWriter csvTableWriter, TEntity entity)
 {
     csvTableWriter.SetValues(entity);
     await csvTableWriter.WriteAsync();
 }