Skip to content

Interface IConfigurationSerializer

Namespace: Void.Proxy.Api.Configurations.Serializer
Assembly: Void.Proxy.Api.dll

public interface IConfigurationSerializer

Methods

Deserialize<TConfiguration>(string)

Deserializes configuration text into an instance of TConfiguration.

TConfiguration Deserialize<TConfiguration>(string source) where TConfiguration : notnull

Parameters

source string

The serialized configuration text to parse and map; this value must not be null.

Returns

TConfiguration

A configuration instance cast to TConfiguration.

Type Parameters

TConfiguration

The expected configuration type.

Examples

var value = serializer.Deserialize<NetworkConfiguration>(sourceText);

Remarks

This member is a typed wrapper around that passes typeof(TConfiguration) as the target type.

The built-in serializer implementation parses TOML and maps it with configured options, then validates that the resulting object can be cast to TConfiguration.

Exceptions

InvalidConfigurationException

Thrown when source cannot be parsed, when it cannot be mapped to TConfiguration, or when the mapped result is not assignable to TConfiguration.

See Also

IConfigurationSerializer.Deserialize(string, Type)

Deserialize(string, Type)

Deserializes configuration text into an instance of a runtime-specified configuration type.

object Deserialize(string source, Type configurationType)

Parameters

source string

The serialized configuration text to parse and map; this value must not be null.

configurationType Type

The target configuration to materialize.

Returns

object

The deserialized configuration object typed as .

Examples

var value = serializer.Deserialize(sourceText, typeof(NetworkConfiguration));

Remarks

The built-in serializer implementation first parses source as TOML, then maps the parsed document to configurationType using serializer options.

This overload performs no compile-time type checks, so callers are responsible for casting the returned value to the expected runtime type.

Exceptions

InvalidConfigurationException

Thrown when parsing fails or when the serialized content cannot be converted to configurationType.

See Also

IConfigurationSerializer.Deserialize<TConfiguration>(string), Type

Serialize<TConfiguration>()

string Serialize<TConfiguration>() where TConfiguration : notnull

Returns

string

Type Parameters

TConfiguration

Serialize(object)

string Serialize(object configuration)

Parameters

configuration object

Returns

string

Serialize<TConfiguration>(TConfiguration?)

string Serialize<TConfiguration>(TConfiguration? configuration) where TConfiguration : notnull

Parameters

configuration TConfiguration?

Returns

string

Type Parameters

TConfiguration

Serialize(object?, Type)

string Serialize(object? configuration, Type configurationType)

Parameters

configuration object?

configurationType Type

Returns

string