Table of Contents

ConfigurationWriteOptions Class

Definition

Namespace
Bodu.Text.Configuration
Assembly
Bodu.Text.Configuration.dll
Package
Bodu.Text.Configuration 1.3.0
Source
ConfigurationWriteOptions.Presets.cs

Controls how a configuration document is emitted by Save(IniDocumentBase, string, ConfigurationWriteOptions?) and related methods.

public sealed class ConfigurationWriteOptions
Inheritance
ConfigurationWriteOptions
Inherited Members
Extension Methods

Remarks

The writer aims to be round-trip preserving by default: PreserveComments and WriteInlineComments retain commentary from the original document, and InsertBlankLineBetweenSections keeps section blocks visually separated. Override these when emitting a freshly built document, or when generating a minimized variant for transport.

Profile only labels the option set: the writer reads the individual properties. Start from a preset or For(ConfigurationProfile) to take a profile's formatting choices, and set the properties that differ.

Encoding defaults to UTF-8 without a byte-order mark to match the EditorConfig file convention; supply an alternative explicitly when interoperating with a host that expects a BOM or a different code page. NewLine defaults to a single LF - switch to "\r\n" for hosts that require CRLF on output. Every property is init-only, so instances are safe to cache and share across threads.

ConfigurationDocument.Save(document, "team.boduconfig", new ConfigurationWriteOptions
{
    KeyValueSeparator = " = ",
    PreserveComments = true,
    InsertBlankLineBetweenSections = true,
});

Constructors

ConfigurationWriteOptions()

public ConfigurationWriteOptions()

Properties

Bodu

Gets the canonical option set for the default Bodu profile.

public static ConfigurationWriteOptions Bodu { get; }

Property Value

ConfigurationWriteOptions

A cached default options instance.

CommentPrefix

Gets a comment prefix character. The writer does not use it: every IniComment is written with its own Prefix, and the writer emits no comment that lacks one.

public char CommentPrefix { get; init; }

Property Value

char

The comment prefix; it has no effect on the output.

EditorConfigCompatible

Gets the canonical option set for the EditorConfig-compatible profile: inline comments suppressed.

public static ConfigurationWriteOptions EditorConfigCompatible { get; }

Property Value

ConfigurationWriteOptions

A cached EditorConfig-compatible options instance.

Encoding

Gets the encoding used when writing to a byte stream or file. The default is UTF-8 without BOM.

public Encoding Encoding { get; init; }

Property Value

Encoding

The output encoding.

InsertBlankLineBetweenSections

Gets a value indicating whether a blank line is inserted between sections.

public bool InsertBlankLineBetweenSections { get; init; }

Property Value

bool

true to insert a blank line.

KeyValueSeparator

Gets the string used to separate keys and values (typically = ).

public string KeyValueSeparator { get; init; }

Property Value

string

The separator string.

NewLine

Gets the line-ending sequence to emit between lines.

public string NewLine { get; init; }

Property Value

string

The line terminator string.

Normalized

Gets the canonical option set for normalized output, the one For(ConfigurationProfile) gives for Strict: leading and inline comments dropped, a blank line between sections, and deterministic spacing. Sections and properties keep their document order.

public static ConfigurationWriteOptions Normalized { get; }

Property Value

ConfigurationWriteOptions

A cached normalized options instance.

PreserveComments

Gets a value indicating whether existing leading comments should be preserved in the output.

public bool PreserveComments { get; init; }

Property Value

bool

true when comments are preserved.

Profile

Gets the profile this option set was created from. The default is Bodu.

public ConfigurationProfile Profile { get; init; }

Property Value

ConfigurationProfile

The profile the option set is labeled with.

Remarks

The property is informational: the writer does not read it, and setting it changes no other property. Use For(ConfigurationProfile) or a preset to select a profile's formatting choices.

WriteInlineComments

Gets a value indicating whether inline comments should be emitted on property lines.

public bool WriteInlineComments { get; init; }

Property Value

bool

true when inline comments are emitted.

Methods

For(ConfigurationProfile)

Returns the canonical option set for the specified profile.

public static ConfigurationWriteOptions For(ConfigurationProfile profile)

Parameters

profile ConfigurationProfile

The profile to materialize.

Returns

ConfigurationWriteOptions

An options instance configured for profile.

Exceptions

ArgumentOutOfRangeException

profile is not a defined value.

Applies to

ProductVersions
.NET8, 10