IKeyedServiceCollection<TKey,TService>.GetService 方法

定义

重载

GetService(TKey)
GetService(IServiceProvider, TKey)

获取具有指定键的服务。

GetService(TKey)

public TService GetService (TKey key);
abstract member GetService : 'Key -> 'Service
Public Function GetService (key As TKey) As TService

参数

key
TKey

返回

TService

适用于

GetService(IServiceProvider, TKey)

Source:
IKeyedServiceCollection.cs

获取具有指定键的服务。

public TService GetService (IServiceProvider services, TKey key);
abstract member GetService : IServiceProvider * 'Key -> 'Service
Public Function GetService (services As IServiceProvider, key As TKey) As TService

参数

services
IServiceProvider

服务提供程序。

key
TKey

键。

返回

TService

具有指定密钥的服务。

适用于