TomlTypeInfo Class

Represents metadata and operations for a serializable type.

public abstract class TomlTypeInfo

Constructors

NameDescription
TomlTypeInfo(Type, TomlSerializerOptions)Initializes a new instance of the TomlTypeInfo class.

TomlTypeInfo(Type, TomlSerializerOptions)

TomlTypeInfo.cs

Initializes a new instance of the TomlTypeInfo class.

protected TomlTypeInfo(Type type, TomlSerializerOptions options)

Parameters

type Type
The represented CLR type.
options TomlSerializerOptions
The options associated with the metadata.

Properties

NameDescription
OptionsGets the options associated with this metadata instance.
TypeGets the CLR type represented by this metadata.
WritesTableGets a value indicating whether this metadata writes values as TOML tables.

Gets the options associated with this metadata instance.

public TomlSerializerOptions Options { get; }

Property value

TomlSerializerOptions

Gets the CLR type represented by this metadata.

public Type Type { get; }

Property value

Type

WritesTable

TomlTypeInfo.cs

Gets a value indicating whether this metadata writes values as TOML tables.

public virtual bool WritesTable { get; }

Property value

bool

Methods

NameDescription
ReadAsObject(TomlReader)Reads a value from an existing TOML reader.
ReadInto(TomlReader, object?)Reads a value from an existing TOML reader, populating an existing CLR instance when supported.
Write(TomlWriter, object?)Writes a value to an existing TOML writer.

ReadAsObject(TomlReader)

Reads a value from an existing TOML reader.

public abstract object? ReadAsObject(TomlReader reader)

Parameters

reader TomlReader

Returns

object?

ReadInto(TomlReader, object?)

TomlTypeInfo.cs

Reads a value from an existing TOML reader, populating an existing CLR instance when supported.

public virtual object? ReadInto(TomlReader reader, object? existingValue)

Parameters

reader TomlReader
The TOML reader positioned at the value to read.
existingValue object?
The existing CLR value to populate, if any.

Returns

object? The populated or replacement value.

Remarks

The return value is the effective deserialized value for the caller to use. Implementations can return the original populated instance or a replacement value. Returning the effective value is required for populate scenarios involving structs and nullable value types, where a modified copy must be reassigned by the caller. The default implementation ignores existingValue and falls back to TomlTypeInfo.ReadAsObject, which preserves replace semantics for metadata that does not support in-place population.

Write(TomlWriter, object?)

Writes a value to an existing TOML writer.

public abstract void Write(TomlWriter writer, object? value)

Parameters

writer TomlWriter
value object?