Compartir a través de


ConfigurationExtensibility.GetPersistedStateAsync<T> Method

Definition

Gets the persisted value for an extension scoped runtime state.

public virtual System.Threading.Tasks.Task<T?> GetPersistedStateAsync<T> (string moniker, T? defaultValue, System.Threading.CancellationToken cancellationToken = default);
abstract member GetPersistedStateAsync : string * 'T * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'T>
override this.GetPersistedStateAsync : string * 'T * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'T>
Public Overridable Function GetPersistedStateAsync(Of T) (moniker As String, defaultValue As T, Optional cancellationToken As CancellationToken = Nothing) As Task(Of T)

Type Parameters

T

Type of the value. The value is serialized/deserialized using System.Text.Json library.

Parameters

moniker
String

Moniker for the entry to get.

defaultValue
T

Default value to return if moniker is not found.

cancellationToken
CancellationToken

Cancellation token to monitor.

Returns

Task<T>

Value of the moniker if found in persisted state or default value if not found.

Remarks

Persisted state monikers are meant for values that persists across sessions but are not user configurable and only written/retrieved by the extension at runtime.

Applies to