IniDocument Class
Definition
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
utf8IniReadOnlySpan<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
utf8IniReadOnlySpan<byte>The INI source bytes.
readerOptionsIniReaderOptionsThe source-order reader options.
documentOptionsIniDocumentOptionsThe 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
inistringThe INI source text.
Returns
- IniDocument
The parsed document.
Exceptions
- ArgumentNullException
Thrown when
iniis null.- IniFormatException
Thrown when the text is not valid INI.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |