Table of Contents

Interface ISectionStoreConfigurationOptions

Namespace
Arc4u.Configuration.Store
Assembly
Arc4u.Configuration.Store.dll

Configuration options for persisted configuration sections

public interface ISectionStoreConfigurationOptions

Methods

AddFromConfiguration<TValue>(string, Func<IConfigurationSection, TValue?>)

Add a section from the existing configuration to be persisted, bound by bind. Because the binding is written in the application, where TValue is known, the configuration binding generator of the application generates it.

[RequiresUnreferencedCode("The value is serialized with reflection. Use the overload taking a JsonTypeInfo<TValue>, generated by a JsonSerializerContext in your application.")]
[RequiresDynamicCode("The value is serialized with reflection. Use the overload taking a JsonTypeInfo<TValue>, generated by a JsonSerializerContext in your application.")]
ISectionStoreConfigurationOptions AddFromConfiguration<TValue>(string key, Func<IConfigurationSection, TValue?> bind)

Parameters

key string

the name of the section

bind Func<IConfigurationSection, TValue>

The function that reads the section, typically section => section.Get<MyOptions>().

Returns

ISectionStoreConfigurationOptions

The options, to chain calls.

Type Parameters

TValue

The type of the value in the existing configuration

Remarks

The value is serialized with reflection, which trimming and native AOT do not support: use AddFromConfiguration<TValue>(string, Func<IConfigurationSection, TValue?>, JsonTypeInfo<TValue>) there.

AddFromConfiguration<TValue>(string, Func<IConfigurationSection, TValue?>, JsonTypeInfo<TValue>)

Add a section from the existing configuration to be persisted, bound by bind and serialized with typeInfo. Because both are generated in the application, where TValue is known (the binding by the configuration binding generator, the metadata by a JsonSerializerContext), it works with trimming and native AOT.

ISectionStoreConfigurationOptions AddFromConfiguration<TValue>(string key, Func<IConfigurationSection, TValue?> bind, JsonTypeInfo<TValue> typeInfo)

Parameters

key string

the name of the section

bind Func<IConfigurationSection, TValue>

The function that reads the section, typically section => section.Get<MyOptions>().

typeInfo JsonTypeInfo<TValue>

The Json metadata of TValue, typically MyJsonContext.Default.MyOptions.

Returns

ISectionStoreConfigurationOptions

The options, to chain calls.

Type Parameters

TValue

The type of the value in the existing configuration

Add<TValue>(string)

Add a section from the existing configuration to be persisted.

[RequiresUnreferencedCode("The section is bound and serialized with reflection. Use AddFromConfiguration with a binding function, e.g. s => s.Get<MyOptions>(), and a JsonTypeInfo<TValue>, so both are generated in your application.")]
[RequiresDynamicCode("The section is bound and serialized with reflection. Use AddFromConfiguration with a binding function, e.g. s => s.Get<MyOptions>(), and a JsonTypeInfo<TValue>, so both are generated in your application.")]
ISectionStoreConfigurationOptions Add<TValue>(string key)

Parameters

key string

the name of the section

Returns

ISectionStoreConfigurationOptions

Type Parameters

TValue

The type of the value in the existing configuration

Remarks

The section is bound and serialized with reflection, which trimming and native AOT do not support: use AddFromConfiguration<TValue>(string, Func<IConfigurationSection, TValue?>, JsonTypeInfo<TValue>) there.

Add<TValue>(string, TValue?)

Add a section with a specific value to be persisted

[RequiresUnreferencedCode("The value is serialized with reflection. Use the overload taking a JsonTypeInfo<TValue>, generated by a JsonSerializerContext in your application.")]
[RequiresDynamicCode("The value is serialized with reflection. Use the overload taking a JsonTypeInfo<TValue>, generated by a JsonSerializerContext in your application.")]
ISectionStoreConfigurationOptions Add<TValue>(string key, TValue? value)

Parameters

key string

the name of the section

value TValue

the value of the section

Returns

ISectionStoreConfigurationOptions

Type Parameters

TValue

The type of the value

Remarks

The value is serialized with reflection, which trimming and native AOT do not support: use Add<TValue>(string, TValue?, JsonTypeInfo<TValue>) there.

Add<TValue>(string, TValue?, JsonTypeInfo<TValue>)

Add a section with a specific value to be persisted, serialized with typeInfo. Because the metadata is generated in the application, where TValue is known, it works with trimming and native AOT.

ISectionStoreConfigurationOptions Add<TValue>(string key, TValue? value, JsonTypeInfo<TValue> typeInfo)

Parameters

key string

the name of the section

value TValue

the value of the section

typeInfo JsonTypeInfo<TValue>

The Json metadata of TValue, typically MyJsonContext.Default.MyOptions.

Returns

ISectionStoreConfigurationOptions

The options, to chain calls.

Type Parameters

TValue

The type of the value