Dela via


PartitionedRateLimiter<TResource>.WithTranslatedKey<TOuter> Method

Definition

Translates PartitionedRateLimiter<TOuter> into the current PartitionedRateLimiter<TResource> using the keyAdapter to translate TOuter to TResource.

public System.Threading.RateLimiting.PartitionedRateLimiter<TOuter> WithTranslatedKey<TOuter> (Func<TOuter,TResource> keyAdapter, bool leaveOpen);
member this.WithTranslatedKey : Func<'Outer, 'Resource> * bool -> System.Threading.RateLimiting.PartitionedRateLimiter<'Outer>
Public Function WithTranslatedKey(Of TOuter) (keyAdapter As Func(Of TOuter, TResource), leaveOpen As Boolean) As PartitionedRateLimiter(Of TOuter)

Type Parameters

TOuter

The type to translate into TResource.

Parameters

keyAdapter
Func<TOuter,TResource>

The function to be called every time a TOuter is passed to PartitionedRateLimiter<TOuter>.Acquire(TOuter, int) or PartitionedRateLimiter<TOuter>.WaitAsync(TOuter, int, CancellationToken).

keyAdapter should be implemented in a thread-safe way.

leaveOpen
Boolean

Specifies whether the returned PartitionedRateLimiter<TResource> will dispose the wrapped PartitionedRateLimiter<TResource>.

Returns

A new PartitionedRateLimiter<TOuter> that translates TOuter to TResource and calls the inner PartitionedRateLimiter<TResource>.

Applies to