Düzenle

Aracılığıyla paylaş


KeyedServiceCollectionExtensions.GetRequiredServiceByKey<TKey,TService> Method

Definition

Acquire a service by key, throwing if the service is not found.

public static TService GetRequiredServiceByKey<TKey,TService> (this IServiceProvider services, TKey key) where TService : class;
static member GetRequiredServiceByKey : IServiceProvider * 'Key -> 'Service (requires 'Service : null)
<Extension()>
Public Function GetRequiredServiceByKey(Of TKey, TService) (services As IServiceProvider, key As TKey) As TService

Type Parameters

TKey

The service key type.

TService

The service type.

Parameters

services
IServiceProvider

The service provider.

key
TKey

The service key.

Returns

TService

The service.

Applies to