CsvRecordWriter()
protected CsvRecordWriter()Creates a record writer whose columns have their own names.
Class in CsvHelper
Writes records of type T as fields of a CsvWriter, in the columns that a CsvRecordMapper<T> reads. The CsvHelper source generator writes one for each CsvRecordAttribute type; CsvWriter.WriteRecords<T>(IEnumerable<T>) and the other record methods of the writer use it.
public abstract class CsvRecordWriter<T>CsvHelperCsvHelper.dllA record writer does not depend on the CsvWriter it writes to and does not change after it is created, so it can be used with any writer, on any thread.
To write one by hand, write the column names in WriteHeader (with WriteColumnName, which puts ColumnPrefix in front) and the fields of a record in Write, as many as FieldCount says, with the writer's WriteField methods. Neither ends the record. Register it with CsvRecordWriter.Register.
protected CsvRecordWriter()Creates a record writer whose columns have their own names.
protected CsvRecordWriter(string columnPrefix)Creates a record writer that puts columnPrefix in front of the names of its columns.
columnPrefixstring"Ship ", for a record written as a member of another record (CsvColumnAttribute.Prefix); "" for none.columnPrefix is null.protected string ColumnPrefix { get; }The text that WriteColumnName puts in front of each column name; "" for none.
public abstract int FieldCount { get; }The number of fields that Write and WriteHeader write.
protected CsvRecordWriter<TNested> NestedWriter<TNested>(string prefix)Creates the record writer of a member whose type is itself a record type, which writes its columns in the same records, with ColumnPrefix and then prefix in front of their names.
TNestedprefixstring"" for none.TNested.prefix is null.TNested has no record writer, or its records cannot be written, or the nested record writers lead back to their own type without end.public abstract void Write(CsvWriter writer, T record)Writes the values of a record as fields of the current record, without ending it.
writerCsvWriterrecordTnull.protected void WriteColumnName(CsvWriter writer, string name)Writes ColumnPrefix followed by name as a field: a column name of the header.
writerCsvWriternamestringwriter or name is null.public virtual void WriteEmpty(CsvWriter writer)Writes FieldCount empty fields, for a nested record that is null, without ending the record.
writerCsvWriterwriter is null.public abstract void WriteHeader(CsvWriter writer)Writes the names of the columns as fields of the current record, without ending it.
writerCsvWriter