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
keystringthe name of the section
bindFunc<IConfigurationSection, TValue>The function that reads the section, typically
section => section.Get<MyOptions>().
Returns
- ISectionStoreConfigurationOptions
The options, to chain calls.
Type Parameters
TValueThe 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
keystringthe name of the section
bindFunc<IConfigurationSection, TValue>The function that reads the section, typically
section => section.Get<MyOptions>().typeInfoJsonTypeInfo<TValue>The Json metadata of
TValue, typicallyMyJsonContext.Default.MyOptions.
Returns
- ISectionStoreConfigurationOptions
The options, to chain calls.
Type Parameters
TValueThe 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
keystringthe name of the section
Returns
Type Parameters
TValueThe 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
keystringthe name of the section
valueTValuethe value of the section
Returns
Type Parameters
TValueThe 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
keystringthe name of the section
valueTValuethe value of the section
typeInfoJsonTypeInfo<TValue>The Json metadata of
TValue, typicallyMyJsonContext.Default.MyOptions.
Returns
- ISectionStoreConfigurationOptions
The options, to chain calls.
Type Parameters
TValueThe type of the value