// Copyright 2009-2022 Josh Close // This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0. // See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0. // https://github.com/JoshClose/CsvHelper using System; using CsvHelper.Configuration; using CsvHelper.TypeConversion; namespace CsvHelper { /// /// Defines methods used to write a CSV row. /// public interface IWriterRow { /// /// The header record. /// string[] HeaderRecord { get; } /// /// The current row. /// int Row { get; } /// /// The current field index. /// int Index { get; } /// /// Gets the writing context. /// CsvContext Context { get; } /// /// Gets or sets the configuration. /// IWriterConfiguration Configuration { get; } /// /// Writes a field that has already been converted to a /// from an . /// If the field is null, it won't get written. A type converter /// will always return a string, even if field is null. If the /// converter returns a null, it means that the converter has already /// written data, and the returned value should not be written. /// /// The converted field to write. /// The type of the field before it was converted into a string. void WriteConvertedField(string field, Type fieldType); /// /// Writes the field to the CSV file. The field /// may get quotes added to it. /// When all fields are written for a record, /// must be called /// to complete writing of the current record. /// /// The field to write. void WriteField(string field); /// /// Writes the field to the CSV file. This will /// ignore any need to quote and ignore /// /// and just quote based on the shouldQuote /// parameter. /// When all fields are written for a record, /// must be called /// to complete writing of the current record. /// /// The field to write. /// True to quote the field, otherwise false. void WriteField(string field, bool shouldQuote); /// /// Writes the field to the CSV file. /// When all fields are written for a record, /// must be called /// to complete writing of the current record. /// /// The type of the field. /// The field to write. void WriteField(T field); /// /// Writes the field to the CSV file. /// When all fields are written for a record, /// must be called /// to complete writing of the current record. /// /// The type of the field. /// The field to write. /// The converter used to convert the field into a string. void WriteField(T field, ITypeConverter converter); /// /// Writes the field to the CSV file /// using the given . /// When all fields are written for a record, /// must be called /// to complete writing of the current record. /// /// The type of the field. /// The type of the converter. /// The field to write. void WriteField(T field); /// /// Writes a comment. /// /// The comment to write. void WriteComment(string comment); /// /// Writes the header record from the given members. /// /// The type of the record. void WriteHeader(); /// /// Writes the header record from the given members. /// /// The type of the record. void WriteHeader(Type type); /// /// Writes the record to the CSV file. /// /// The type of the record. /// The record to write. void WriteRecord(T record); } }