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
sectionStoreISectionStoreThe section store.
keystringThe name of the section.
typeInfoJsonTypeInfo<TValue>The Json metadata of
TValue, typicallyMyJsonContext.Default.MyOptions.cancellationTokenCancellationTokenA 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
TValueThe 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
sectionStoreISectionStorekeystringcancellationTokenCancellationToken
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
sectionStoreISectionStoreThe section store.
keystringThe name of the section.
valueTValueThe value.
typeInfoJsonTypeInfo<TValue>The Json metadata of
TValue, typicallyMyJsonContext.Default.MyOptions.cancellationTokenCancellationTokenA token to cancel the operation.
Returns
Type Parameters
TValueThe 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
sectionStoreISectionStorekeystringvalueTValuecancellationTokenCancellationToken
Returns
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
sectionStoreISectionStoreentitySectionEntitycancellationTokenCancellationToken