KeyedServiceCollectionExtensions.GetServiceByName<TService> 方法

定义

按名称获取服务。

public static TService GetServiceByName<TService> (this IServiceProvider services, string name) where TService : class;
static member GetServiceByName : IServiceProvider * string -> 'Service (requires 'Service : null)
<Extension()>
Public Function GetServiceByName(Of TService As Class) (services As IServiceProvider, name As String) As TService

类型参数

TService

服务类型。

参数

services
IServiceProvider

服务提供程序。

name
String

服务名称。

返回

TService

服务。

适用于