Table of Contents

Class ISectionStoreExtensions

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

Extension methods that simplify the use of an ISectionStore.

public static class ISectionStoreExtensions
Inheritance
ISectionStoreExtensions
Inherited Members

Methods

TryGetValueAsync<TValue>(ISectionStore, string, JsonTypeInfo<TValue>, CancellationToken)

Try to get a value of type TValue from the section named key, deserialized with typeInfo.

public static Task<(bool Valid, TValue? Value)> TryGetValueAsync<TValue>(this ISectionStore sectionStore, string key, JsonTypeInfo<TValue> typeInfo, CancellationToken cancellationToken)

Parameters

sectionStore ISectionStore

The section store.

key string

The name of the section.

typeInfo JsonTypeInfo<TValue>

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

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task<(bool Valid, TValue Value)>

A tuple: if the Valid member is true, the Value member contains the value. False if there is no section named key

Type Parameters

TValue

The type of the value.

TryGetValueAsync<TValue>(ISectionStore, string, CancellationToken)

Try to get a value of type TValue from the section named key

[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 static Task<(bool Valid, TValue? Value)> TryGetValueAsync<TValue>(this ISectionStore sectionStore, string key, CancellationToken cancellationToken)

Parameters

sectionStore ISectionStore
key string
cancellationToken CancellationToken

Returns

Task<(bool Valid, TValue Value)>

A tuple: if the Valid member is true, the Value member contains the value. False if there is no section named key

Type Parameters

TValue

Remarks

The value is deserialized with reflection, which trimming and native AOT do not support: use the overload taking a JsonTypeInfo<T> there.

TrySetValueAsync<TValue>(ISectionStore, string, TValue?, JsonTypeInfo<TValue>, CancellationToken)

Try to set a value of type TValue to the section named key, serialized with typeInfo.

public static Task<bool> TrySetValueAsync<TValue>(this ISectionStore sectionStore, string key, TValue? value, JsonTypeInfo<TValue> typeInfo, CancellationToken cancellationToken)

Parameters

sectionStore ISectionStore

The section store.

key string

The name of the section.

value TValue

The value.

typeInfo JsonTypeInfo<TValue>

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

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task<bool>

True if the value was set successfully. False if there is no section named key

Type Parameters

TValue

The type of the value.

TrySetValueAsync<TValue>(ISectionStore, string, TValue?, CancellationToken)

Try to set a value of type TValue to the section named key

[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 static Task<bool> TrySetValueAsync<TValue>(this ISectionStore sectionStore, string key, TValue? value, CancellationToken cancellationToken)

Parameters

sectionStore ISectionStore
key string
value TValue
cancellationToken CancellationToken

Returns

Task<bool>

True if the value was set successfully. False if there is no section named key

Type Parameters

TValue

Remarks

The value is serialized with reflection, which trimming and native AOT do not support: use the overload taking a JsonTypeInfo<T> there.

UpdateAsync(ISectionStore, SectionEntity, CancellationToken)

Update an entity in the store

public static Task UpdateAsync(this ISectionStore sectionStore, SectionEntity entity, CancellationToken cancellationToken)

Parameters

sectionStore ISectionStore
entity SectionEntity
cancellationToken CancellationToken

Returns

Task