英語で読む

次の方法で共有


ServiceProviderKeyedServiceExtensions.GetRequiredKeyedService メソッド

定義

オーバーロード

GetRequiredKeyedService(IServiceProvider, Type, Object)

から 型 serviceType のサービスを取得します IServiceProvider

GetRequiredKeyedService<T>(IServiceProvider, Object)

から 型 T のサービスを取得します IServiceProvider

GetRequiredKeyedService(IServiceProvider, Type, Object)

ソース:
ServiceProviderKeyedServiceExtensions.cs
ソース:
ServiceProviderKeyedServiceExtensions.cs
ソース:
ServiceProviderKeyedServiceExtensions.cs
ソース:
ServiceProviderKeyedServiceExtensions.cs

から 型 serviceType のサービスを取得します IServiceProvider

C#
public static object GetRequiredKeyedService (this IServiceProvider provider, Type serviceType, object? serviceKey);

パラメーター

provider
IServiceProvider

サービス オブジェクトの取得元の IServiceProvider

serviceType
Type

取得対象となるサービスの型を指定するオブジェクト。

serviceKey
Object

取得するサービス オブジェクトのキーを指定する オブジェクト。

戻り値

serviceType 型のサービス オブジェクト。

例外

serviceType 型のサービスはありません。

適用対象

.NET 9 およびその他のバージョン
製品 バージョン
.NET 6, 7, 8, 9
.NET Framework 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

GetRequiredKeyedService<T>(IServiceProvider, Object)

ソース:
ServiceProviderKeyedServiceExtensions.cs
ソース:
ServiceProviderKeyedServiceExtensions.cs
ソース:
ServiceProviderKeyedServiceExtensions.cs
ソース:
ServiceProviderKeyedServiceExtensions.cs

から 型 T のサービスを取得します IServiceProvider

C#
public static T GetRequiredKeyedService<T> (this IServiceProvider provider, object? serviceKey);

型パラメーター

T

取得するサービス オブジェクトの型。

パラメーター

provider
IServiceProvider

サービス オブジェクトの取得元の IServiceProvider

serviceKey
Object

取得するサービス オブジェクトのキーを指定する オブジェクト。

戻り値

T

T 型のサービス オブジェクト。

例外

T 型のサービスはありません。

適用対象

.NET 9 およびその他のバージョン
製品 バージョン
.NET 6, 7, 8, 9
.NET Framework 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1