Class TomlSerializer
Provides methods for serializing and deserializing TOML data.
public static class TomlSerializer
- Inheritance
-
TomlSerializer
- Inherited Members
Methods
DeserializeAsync(Stream, CancellationToken)
Asynchronously deserializes TOML content from a stream to a TomlTable.
public static Task<TomlTable> DeserializeAsync(Stream tomlStream, CancellationToken cancellationToken = default)
Parameters
tomlStreamStreamThe stream containing TOML content to deserialize.
cancellationTokenCancellationTokenA cancellation token that can be used to cancel the operation.
Returns
- Task<TomlTable>
A task that represents the asynchronous operation. The task result contains the deserialized TomlTable.
Exceptions
- ArgumentNullException
Thrown when
tomlStreamisnull.- TomlSerializerException
Thrown when the TOML content cannot be parsed.
- OperationCanceledException
Thrown when the operation is canceled.
DeserializeAsync(string, TomlSettings?, CancellationToken)
Asynchronously deserializes a TOML string to a TomlTable using the specified settings.
public static Task<TomlTable> DeserializeAsync(string toml, TomlSettings? tomlSettings, CancellationToken cancellationToken = default)
Parameters
tomlstringThe TOML content to deserialize.
tomlSettingsTomlSettingsThe settings to use for deserialization. If
null, default settings are used.cancellationTokenCancellationTokenA cancellation token that can be used to cancel the operation.
Returns
- Task<TomlTable>
A task that represents the asynchronous operation. The task result contains the deserialized TomlTable.
Exceptions
- ArgumentNullException
Thrown when
tomlisnull.- TomlSerializerException
Thrown when the TOML content cannot be parsed.
- OperationCanceledException
Thrown when the operation is canceled.
DeserializeAsync(string, CancellationToken)
Asynchronously deserializes a TOML string to a TomlTable.
public static Task<TomlTable> DeserializeAsync(string toml, CancellationToken cancellationToken = default)
Parameters
tomlstringThe TOML content to deserialize.
cancellationTokenCancellationTokenA cancellation token that can be used to cancel the operation.
Returns
- Task<TomlTable>
A task that represents the asynchronous operation. The task result contains the deserialized TomlTable.
Exceptions
- ArgumentNullException
Thrown when
tomlisnull.- TomlSerializerException
Thrown when the TOML content cannot be parsed.
- OperationCanceledException
Thrown when the operation is canceled.
SerializeAsync(TomlToken, Stream, TomlSettings?, CancellationToken)
Asynchronously serializes a TomlToken to a stream in TOML format using the specified settings.
public static Task SerializeAsync(TomlToken tomlToken, Stream stream, TomlSettings? tomlSettings, CancellationToken cancellationToken)
Parameters
tomlTokenTomlTokenThe TOML token to serialize.
streamStreamThe stream to write the serialized TOML content to.
tomlSettingsTomlSettingsThe settings to use for serialization. If
null, default settings are used.cancellationTokenCancellationTokenA cancellation token that can be used to cancel the operation.
Returns
- Task
A task that represents the asynchronous operation.
Exceptions
- ArgumentNullException
Thrown when
tomlTokenorstreamisnull.- TomlSerializerException
Thrown when the token cannot be serialized.
- OperationCanceledException
Thrown when the operation is canceled.
SerializeAsync(TomlToken, Stream, CancellationToken)
Asynchronously serializes a TomlToken to a stream in TOML format.
public static Task SerializeAsync(TomlToken tomlToken, Stream stream, CancellationToken cancellationToken = default)
Parameters
tomlTokenTomlTokenThe TOML token to serialize.
streamStreamThe stream to write the serialized TOML content to.
cancellationTokenCancellationTokenA cancellation token that can be used to cancel the operation.
Returns
- Task
A task that represents the asynchronous operation.
Exceptions
- ArgumentNullException
Thrown when
tomlTokenorstreamisnull.- TomlSerializerException
Thrown when the token cannot be serialized.
- OperationCanceledException
Thrown when the operation is canceled.
SerializeToStringAsync(TomlToken, TomlSettings?, CancellationToken)
Asynchronously serializes a TomlToken to a TOML string using the specified settings.
public static Task<string> SerializeToStringAsync(TomlToken tomlToken, TomlSettings? tomlSettings, CancellationToken cancellationToken)
Parameters
tomlTokenTomlTokenThe TOML token to serialize.
tomlSettingsTomlSettingsThe settings to use for serialization. If
null, default settings are used.cancellationTokenCancellationTokenA cancellation token that can be used to cancel the operation.
Returns
- Task<string>
A task that represents the asynchronous operation. The task result contains the serialized TOML string.
Exceptions
- ArgumentNullException
Thrown when
tomlTokenisnull.- TomlSerializerException
Thrown when the token cannot be serialized.
- OperationCanceledException
Thrown when the operation is canceled.
SerializeToStringAsync(TomlToken, CancellationToken)
Asynchronously serializes a TomlToken to a TOML string.
public static Task<string> SerializeToStringAsync(TomlToken tomlToken, CancellationToken cancellationToken = default)
Parameters
tomlTokenTomlTokenThe TOML token to serialize.
cancellationTokenCancellationTokenA cancellation token that can be used to cancel the operation.
Returns
- Task<string>
A task that represents the asynchronous operation. The task result contains the serialized TOML string.
Exceptions
- ArgumentNullException
Thrown when
tomlTokenisnull.- TomlSerializerException
Thrown when the token cannot be serialized.
- OperationCanceledException
Thrown when the operation is canceled.