3using System.Threading.Tasks;
38 SystemIdentity = systemIdentity ??
throw new ArgumentNullException(nameof(systemIdentity));
40 ArgumentNullException.ThrowIfNull(asyncDelayer);
42 ArgumentNullException.ThrowIfNull(onExpiry);
43 var now = DateTimeOffset.UtcNow;
45 throw new ArgumentOutOfRangeException(nameof(expiry), expiry,
"expiry must be greater than DateTimeOffset.UtcNow!");
49 async Task DisposeOnExipiry(CancellationToken cancellationToken)
54 await asyncDelayer.
Delay(expiry - now, cancellationToken);
56 catch (OperationCanceledException)
For keeping a specific ISystemIdentity alive for a period of time.
readonly Task task
The Task to clean up SystemIdentity.
IdentityCacheObject(ISystemIdentity systemIdentity, IAsyncDelayer asyncDelayer, Action onExpiry, DateTimeOffset expiry)
Initializes a new instance of the IdentityCacheObject class.
ISystemIdentity SystemIdentity
The ISystemIdentity the IdentityCache manages.
async ValueTask DisposeAsync()
readonly CancellationTokenSource cancellationTokenSource
The cancellationTokenSource for the IdentityCache.
Represents a user on the current global::System.Runtime.InteropServices.OSPlatform.
For waiting asynchronously.
Task Delay(TimeSpan timeSpan, CancellationToken cancellationToken)
Create a Task that completes after a given timeSpan .