KeyedServiceCollectionExtensions.GetServiceByKey<TKey,TService> 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
按密钥获取服务。
public static TService GetServiceByKey<TKey,TService> (this IServiceProvider services, TKey key) where TService : class;
static member GetServiceByKey : IServiceProvider * 'Key -> 'Service (requires 'Service : null)
<Extension()>
Public Function GetServiceByKey(Of TKey, TService) (services As IServiceProvider, key As TKey) As TService
类型参数
- TKey
服务密钥类型。
- TService
服务类型。
参数
- services
- IServiceProvider
服务提供程序。
- key
- TKey
服务密钥。
返回
TService
服务。