TomlTypeInfo Class
Represents metadata and operations for a serializable type.
public abstract class TomlTypeInfoConstructors
| Name | Description |
|---|---|
| TomlTypeInfo(Type, TomlSerializerOptions) | Initializes a new instance of the TomlTypeInfo class. |
TomlTypeInfo(Type, TomlSerializerOptions)
TomlTypeInfo.csInitializes a new instance of the TomlTypeInfo class.
protected TomlTypeInfo(Type type, TomlSerializerOptions options)Parameters
typeType- The represented CLR type.
optionsTomlSerializerOptions- The options associated with the metadata.
Properties
| Name | Description |
|---|---|
| Options | Gets the options associated with this metadata instance. |
| Type | Gets the CLR type represented by this metadata. |
| WritesTable | Gets a value indicating whether this metadata writes values as TOML tables. |
Options
TomlTypeInfo.csGets the options associated with this metadata instance.
public TomlSerializerOptions Options { get; }Property value
Type
TomlTypeInfo.csWritesTable
TomlTypeInfo.csMethods
| Name | Description |
|---|---|
| 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)ReadInto(TomlReader, object?)
TomlTypeInfo.csReads a value from an existing TOML reader, populating an existing CLR instance when supported.
public virtual object? ReadInto(TomlReader reader, object? existingValue)Parameters
readerTomlReader- The TOML reader positioned at the value to read.
existingValueobject?- 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
writerTomlWritervalueobject?