Table of Contents

IniElement Struct

Definition

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

Represents a single element within an IniDocument - the root object, a section object, or a string value - shaped after System.Text.Json's JsonElement.

public readonly struct IniElement
Inherited Members
Extension Methods

Remarks

The root object's properties are the document's hoisted global keys (string values) followed by its sections (object values); a section object's properties are its key/value entries.

Properties

ValueKind

Gets the value kind of this element.

public IniValueKind ValueKind { get; }

Property Value

IniValueKind

Object for the root or a section; otherwise String.

Methods

EnumerateObject()

Enumerates the properties of an object element: for the root, the hoisted global keys followed by the sections; for a section, its key/value entries.

public IniElement.ObjectEnumerator EnumerateObject()

Returns

IniElement.ObjectEnumerator

An enumerator over the object's properties.

Exceptions

InvalidOperationException

Thrown when this element is not an object.

ObjectDisposedException

Thrown when the owning document has been disposed.

GetProperty(string)

Gets the value element for the specified property name.

public IniElement GetProperty(string name)

Parameters

name string

The property name - a global key or section name on the root, or an entry key on a section.

Returns

IniElement

The value element.

Exceptions

ArgumentNullException

Thrown when name is null.

InvalidOperationException

Thrown when this element is not an object.

KeyNotFoundException

Thrown when the property is not present.

ObjectDisposedException

Thrown when the owning document has been disposed.

GetString()

Gets the string value of an String element.

public string GetString()

Returns

string

The string value.

Exceptions

InvalidOperationException

Thrown when this element is not a string.

ObjectDisposedException

Thrown when the owning document has been disposed.

TryGetProperty(string, out IniElement)

Attempts to get the value element for the specified property name.

public bool TryGetProperty(string name, out IniElement value)

Parameters

name string

The property name - a global key or section name on the root, or an entry key on a section.

value IniElement

When this method returns true, the value element; otherwise the default element.

Returns

bool

true when the property is present; otherwise false.

Exceptions

ArgumentNullException

Thrown when name is null.

InvalidOperationException

Thrown when this element is not an object.

ObjectDisposedException

Thrown when the owning document has been disposed.

Applies to

ProductVersions
.NET8, 10