Table of Contents

IniDocument Class

Definition

Namespace
Bodu.Text.Ini.Document
Assembly
Bodu.Text.Ini.dll
Package
Bodu.Text.Ini 1.0.0
Source
IniDocument.cs

Provides a read-only, pre-parsed view over an INI document, shaped after System.Text.Json's JsonDocument. The document is the normalized two-level object-of-objects: the root object exposes hoisted global keys as string properties and sections as object properties. Comment trivia is not retained.

public sealed class IniDocument : IDisposable
Inheritance
IniDocument
Implements
Inherited Members
Extension Methods

Remarks

The document owns a normalized store of decoded entries - with the duplicate-section and duplicate-key policies already applied - and must be disposed when no longer needed; every IniElement obtained from it becomes invalid once the document is disposed.

Properties

RootElement

Gets the root element, which is always an object.

public IniElement RootElement { get; }

Property Value

IniElement

The root IniElement.

Exceptions

ObjectDisposedException

Thrown when the document has been disposed.

Methods

Dispose()

Releases the document's backing store. Elements obtained from this document must not be used afterward.

public void Dispose()

Parse(ReadOnlySpan<byte>)

Parses the supplied UTF-8 bytes into a read-only INI document using the default reader and document options.

public static IniDocument Parse(ReadOnlySpan<byte> utf8Ini)

Parameters

utf8Ini ReadOnlySpan<byte>

The INI source bytes.

Returns

IniDocument

The parsed document.

Exceptions

IniFormatException

Thrown when the bytes are not valid INI.

Parse(ReadOnlySpan<byte>, IniReaderOptions, IniDocumentOptions)

Parses the supplied UTF-8 bytes into a read-only INI document using the supplied reader and document options.

public static IniDocument Parse(ReadOnlySpan<byte> utf8Ini, IniReaderOptions readerOptions, IniDocumentOptions documentOptions)

Parameters

utf8Ini ReadOnlySpan<byte>

The INI source bytes.

readerOptions IniReaderOptions

The source-order reader options.

documentOptions IniDocumentOptions

The document-model duplicate policies.

Returns

IniDocument

The parsed document.

Exceptions

IniFormatException

Thrown when the bytes are not valid INI, or when a duplicate section, duplicate key, or global-key/section-name collision violates the configured policies.

Parse(string)

Parses the supplied INI text into a read-only INI document.

public static IniDocument Parse(string ini)

Parameters

ini string

The INI source text.

Returns

IniDocument

The parsed document.

Exceptions

ArgumentNullException

Thrown when ini is null.

IniFormatException

Thrown when the text is not valid INI.

Applies to

ProductVersions
.NET8, 10