Table of Contents

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

key string

The name of the section.

value string

The 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

string

Value

A Json representation of the value, wrapped in a Arc4u.Configuration.Store.Internals.ValueHolder<TValue>

public string Value { get; }

Property Value

string

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

typeInfo JsonTypeInfo<TValue>

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

Returns

TValue

The value.

Type Parameters

TValue

The 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

value TValue

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

value TValue

The value.

typeInfo JsonTypeInfo<TValue>

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

Type Parameters

TValue

The type of the value.