IniSerializerOptions Class
Definition
Provides configuration for IniSerializer, controlling property naming, case sensitivity, field inclusion, null handling, the global-section mapping, and the duplicate-section/key policies.
public sealed class IniSerializerOptions
- Inheritance
-
IniSerializerOptions
- Inherited Members
- Extension Methods
Remarks
An options instance becomes read-only the first time it is used for serialization or deserialization; mutating a property after that point throws InvalidOperationException. Share and reuse a configured instance rather than allocating one per call.
Constructors
IniSerializerOptions()
Initializes a new instance of the IniSerializerOptions class with general-purpose defaults.
public IniSerializerOptions()
IniSerializerOptions(IniSerializerDefaults)
Initializes a new instance of the IniSerializerOptions class from the specified defaults.
public IniSerializerOptions(IniSerializerDefaults defaults)
Parameters
defaultsIniSerializerDefaultsThe defaults to initialize from.
Properties
Default
Gets the shared read-only default options.
public static IniSerializerOptions Default { get; }
Property Value
- IniSerializerOptions
The default options.
DefaultIgnoreCondition
Gets or sets the condition under which a property is omitted from the output.
public IgnoreCondition DefaultIgnoreCondition { get; set; }
Property Value
- IgnoreCondition
The default ignore condition.
Exceptions
- InvalidOperationException
Thrown when set after the options have become read-only.
DuplicateKeyBehavior
Gets or sets the policy applied when a key appears more than once within the same section.
public IniDuplicateKeyBehavior DuplicateKeyBehavior { get; set; }
Property Value
- IniDuplicateKeyBehavior
The duplicate-key policy; the default is LastWins.
Exceptions
- InvalidOperationException
Thrown when set after the options have become read-only.
DuplicateSectionBehavior
Gets or sets the policy applied when a section name appears more than once.
public IniDuplicateSectionBehavior DuplicateSectionBehavior { get; set; }
Property Value
- IniDuplicateSectionBehavior
The duplicate-section policy; the default is Merge.
Exceptions
- InvalidOperationException
Thrown when set after the options have become read-only.
GlobalSectionName
Gets or sets the reserved root name the global (pre-section) entries bind to, or null to hoist global keys onto the root object.
public string? GlobalSectionName { get; set; }
Property Value
Remarks
Hoisting maps global keys onto the root object's scalar members, which is ergonomic but cannot represent a document whose root type maps every member to a section. Naming a reserved key routes the global entries to and from the member (or dictionary entry) with that name instead, preserving round-trip fidelity.
Exceptions
- InvalidOperationException
Thrown when set after the options have become read-only.
IncludeFields
Gets or sets a value indicating whether public fields participate in serialization in addition to properties.
public bool IncludeFields { get; set; }
Property Value
Exceptions
- InvalidOperationException
Thrown when set after the options have become read-only.
IsReadOnly
Gets a value indicating whether the options have become read-only.
public bool IsReadOnly { get; }
Property Value
PropertyNameCaseInsensitive
Gets or sets a value indicating whether property-name matching on deserialization ignores case.
public bool PropertyNameCaseInsensitive { get; set; }
Property Value
Exceptions
- InvalidOperationException
Thrown when set after the options have become read-only.
PropertyNamingPolicy
Gets or sets the naming policy applied to property names, or null to use names verbatim.
public NamingPolicy? PropertyNamingPolicy { get; set; }
Property Value
- NamingPolicy
The property naming policy.
Exceptions
- InvalidOperationException
Thrown when set after the options have become read-only.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |