Class SectionEntity
- Namespace
- Arc4u.Configuration.Store
- Assembly
- Arc4u.Configuration.Store.dll
A section antity represents a configuration section named Key and its value as persisted in some store. The user of this type can only modify the value, not create new configuration sections or delete them: sections are specified by the application.
public sealed class SectionEntity
- Inheritance
-
SectionEntity
- Inherited Members
Constructors
SectionEntity()
Creates an empty entity. Used by the configuration provider and by object mappers such as EF Core.
public SectionEntity()
SectionEntity(string, string)
Creates an entity from its persisted representation, typically in a custom ISectionStore that reads its own storage.
public SectionEntity(string key, string value)
Parameters
keystringThe name of the section.
valuestringThe persisted Json representation of the value, exactly as found in Value of an entity received in Add(IEnumerable<SectionEntity>).
Properties
Key
The name of the section holding the value. This is determined at initialization time and cannot be changed
public string Key { get; }
Property Value
Value
A Json representation of the value, wrapped in a Arc4u.Configuration.Store.Internals.ValueHolder<TValue>
public string Value { get; }
Property Value
Methods
GetValue<TValue>()
Return the value associated with the section. It is assumed that the caller knows the correct type.
[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.")]
public TValue? GetValue<TValue>()
Returns
- TValue
Type Parameters
TValue
Remarks
The value is deserialized with reflection, which trimming and native AOT do not support: use GetValue<TValue>(JsonTypeInfo<TValue>) there.
GetValue<TValue>(JsonTypeInfo<TValue>)
Return the value associated with the section, deserialized with typeInfo.
It is assumed that the caller knows the correct type.
public TValue? GetValue<TValue>(JsonTypeInfo<TValue> typeInfo)
Parameters
typeInfoJsonTypeInfo<TValue>The Json metadata of
TValue, typicallyMyJsonContext.Default.MyOptions.
Returns
- TValue
The value.
Type Parameters
TValueThe type of the value.
SetValue<TValue>(TValue?)
Set the value associated with the section.
[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.")]
public void SetValue<TValue>(TValue? value)
Parameters
valueTValue
Type Parameters
TValue
Remarks
The value is serialized with reflection, which trimming and native AOT do not support: use SetValue<TValue>(TValue?, JsonTypeInfo<TValue>) there.
SetValue<TValue>(TValue?, JsonTypeInfo<TValue>)
Set the value associated with the section, serialized with typeInfo.
public void SetValue<TValue>(TValue? value, JsonTypeInfo<TValue> typeInfo)
Parameters
valueTValueThe value.
typeInfoJsonTypeInfo<TValue>The Json metadata of
TValue, typicallyMyJsonContext.Default.MyOptions.
Type Parameters
TValueThe type of the value.