Table of Contents

DelimitedSerializerOptions Class

Definition

Namespace
Bodu.Text.Delimited
Assembly
Bodu.Text.Delimited.dll
Package
Bodu.Text.Delimited 1.3.0
Source
DelimitedSerializerOptions.cs

Provides configuration for DelimitedSerializer, controlling column naming, case sensitivity, field inclusion, and the delimiter, quote, comment character, and header behavior.

public sealed class DelimitedSerializerOptions
Inheritance
DelimitedSerializerOptions
Inherited Members
Extension Methods

Remarks

An options instance becomes read-only the first time it is used; mutating a property after that point throws InvalidOperationException. Share and reuse a configured instance rather than allocating one per call.

Constructors

DelimitedSerializerOptions()

Initializes a new instance of the DelimitedSerializerOptions class with general-purpose defaults.

public DelimitedSerializerOptions()

DelimitedSerializerOptions(DelimitedSerializerDefaults)

Initializes a new instance of the DelimitedSerializerOptions class from the specified defaults.

public DelimitedSerializerOptions(DelimitedSerializerDefaults defaults)

Parameters

defaults DelimitedSerializerDefaults

The defaults to initialize from.

Properties

CommentChar

Gets or sets the comment character, or '\0' to use the default '#'.

public char CommentChar { get; set; }

Property Value

char

The comment character.

Remarks

The serializer passes the comment character to the writer it creates, which quotes a record's first field when the field begins with it, so that a reader that allows comments with the same character reads the record back rather than skipping it (see CommentChar). The serializer never skips comment lines itself: it reads every line as a record, whatever this character is.

The character is also passed to the reader options, whose validation it shares, so it must be a character both the reader and the writer accept (see DelimitedReaderOptions and DelimitedWriterOptions); otherwise serializing or deserializing throws ArgumentException.

Exceptions

InvalidOperationException

Thrown when set after the options have become read-only.

Default

Gets the shared read-only default options.

public static DelimitedSerializerOptions Default { get; }

Property Value

DelimitedSerializerOptions

The default options.

Delimiter

Gets or sets the output field delimiter, or '\0' to use the default comma.

public char Delimiter { get; set; }

Property Value

char

The delimiter character.

Remarks

The serializer passes the delimiter to the reader and writer it creates, so it must be a character both accept (see DelimitedReaderOptions and DelimitedWriterOptions); otherwise serializing or deserializing throws ArgumentException.

Exceptions

InvalidOperationException

Thrown when set after the options have become read-only.

IncludeFields

Gets or sets a value indicating whether public fields participate in addition to properties.

public bool IncludeFields { get; set; }

Property Value

bool

true to include fields; otherwise false.

Exceptions

InvalidOperationException

Thrown when set after the options have become read-only.

IsReadOnly

Gets a value indicating whether the options have become read-only.

public bool IsReadOnly { get; }

Property Value

bool

true once the options have been used; otherwise false.

NoHeader

Gets or sets a value indicating whether the header row is suppressed on the write path and absent on the read path.

public bool NoHeader { get; set; }

Property Value

bool

true for headerless documents; otherwise false.

Remarks

Without a header, the fields of a POCO record bind by position, as a generated IDelimitedRecordFactory<TRecord> binds them: each field to the member the serializer writes in that column, which is the readable members in member order, so the field of a get-only member is skipped and a member past the last field keeps its default value.

Exceptions

InvalidOperationException

Thrown when set after the options have become read-only.

PropertyNameCaseInsensitive

Gets or sets a value indicating whether column-name matching on deserialization ignores case.

public bool PropertyNameCaseInsensitive { get; set; }

Property Value

bool

true to match case-insensitively; otherwise false.

Exceptions

InvalidOperationException

Thrown when set after the options have become read-only.

PropertyNamingPolicy

Gets or sets the naming policy applied to column names, or null to use names verbatim.

public NamingPolicy? PropertyNamingPolicy { get; set; }

Property Value

NamingPolicy

The column naming policy.

Exceptions

InvalidOperationException

Thrown when set after the options have become read-only.

Quote

Gets or sets the output quote character, or '\0' to use the default double quote.

public char Quote { get; set; }

Property Value

char

The quote character.

Remarks

The serializer passes the quote to the reader and writer it creates, so it must be a character both accept (see DelimitedReaderOptions and DelimitedWriterOptions); otherwise serializing or deserializing throws ArgumentException.

Exceptions

InvalidOperationException

Thrown when set after the options have become read-only.

Applies to

ProductVersions
.NET8, 10