ServiceProviderKeyedServiceExtensions.GetKeyedService Method

Definition

Overloads

GetKeyedService(IServiceProvider, Type, Object)

Get service of type serviceType from the IServiceProvider.

GetKeyedService<T>(IServiceProvider, Object)

Get service of type T from the IServiceProvider.

GetKeyedService(IServiceProvider, Type, Object)

Source:
ServiceProviderKeyedServiceExtensions.cs

Get service of type serviceType from the IServiceProvider.

public:
[System::Runtime::CompilerServices::Extension]
 static System::Object ^ GetKeyedService(IServiceProvider ^ provider, Type ^ serviceType, System::Object ^ serviceKey);
public static object? GetKeyedService(this IServiceProvider provider, Type serviceType, object? serviceKey);
static member GetKeyedService : IServiceProvider * Type * obj -> obj
<Extension()>
Public Function GetKeyedService (provider As IServiceProvider, serviceType As Type, serviceKey As Object) As Object

Parameters

provider
IServiceProvider

The IServiceProvider to retrieve the service object from.

serviceType
Type

An object that specifies the type of service object to get.

serviceKey
Object

An object that specifies the key of service object to get.

Returns

A service object of type serviceType or null if there is no such service.

Applies to

GetKeyedService<T>(IServiceProvider, Object)

Source:
ServiceProviderKeyedServiceExtensions.cs
Source:
ServiceProviderKeyedServiceExtensions.cs
Source:
ServiceProviderKeyedServiceExtensions.cs

Get service of type T from the IServiceProvider.

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static T GetKeyedService(IServiceProvider ^ provider, System::Object ^ serviceKey);
public static T? GetKeyedService<T>(this IServiceProvider provider, object? serviceKey);
static member GetKeyedService : IServiceProvider * obj -> 'T
<Extension()>
Public Function GetKeyedService(Of T) (provider As IServiceProvider, serviceKey As Object) As T

Type Parameters

T

The type of service object to get.

Parameters

provider
IServiceProvider

The IServiceProvider to retrieve the service object from.

serviceKey
Object

An object that specifies the key of service object to get.

Returns

T

A service object of type T or null if there is no such service.

Applies to