ConfigurationWriteOptions Class
Definition
- Namespace
- Bodu.Text.Configuration
- Assembly
- Bodu.Text.Configuration.dll
- Package
- Bodu.Text.Configuration 1.0.0
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 selects the default formatting envelope (Bodu, EditorConfig-compatible, or strict). The remaining properties override individual aspects of that envelope without abandoning the rest of its defaults.
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 the comment prefix character used when emitting new comments.
public char CommentPrefix { get; init; }
Property Value
- char
The comment prefix.
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
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: sorted properties, deterministic spacing.
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
Profile
Gets the behaviour profile this option bag represents.
public ConfigurationProfile Profile { get; init; }
Property Value
- ConfigurationProfile
The selected profile.
WriteInlineComments
Gets a value indicating whether inline comments should be emitted on property lines.
public bool WriteInlineComments { get; init; }
Property Value
Methods
For(ConfigurationProfile)
Returns the canonical option set for the specified profile.
public static ConfigurationWriteOptions For(ConfigurationProfile profile)
Parameters
profileConfigurationProfileThe profile to materialize.
Returns
- ConfigurationWriteOptions
An options instance configured for
profile.
Exceptions
- ArgumentOutOfRangeException
profileis not a defined value.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |