ServiceProviderKeyedServiceExtensions.GetRequiredKeyedService Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
GetRequiredKeyedService(IServiceProvider, Type, Object) |
Get service of type |
GetRequiredKeyedService<T>(IServiceProvider, Object) |
Get service of type |
Get service of type serviceType
from the IServiceProvider.
public:
[System::Runtime::CompilerServices::Extension]
static System::Object ^ GetRequiredKeyedService(IServiceProvider ^ provider, Type ^ serviceType, System::Object ^ serviceKey);
public static object GetRequiredKeyedService (this IServiceProvider provider, Type serviceType, object? serviceKey);
static member GetRequiredKeyedService : IServiceProvider * Type * obj -> obj
<Extension()>
Public Function GetRequiredKeyedService (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
.
Exceptions
There is no service of type serviceType
.
Applies to
.NET 9 (package-provided) und andere Versionen
Produkt | Versionen |
---|---|
.NET | 8 (package-provided), 9 (package-provided) |
.NET Framework | 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided) |
.NET Standard | 2.0 (package-provided), 2.1 (package-provided) |
Get service of type T
from the IServiceProvider.
public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
static T GetRequiredKeyedService(IServiceProvider ^ provider, System::Object ^ serviceKey);
public static T GetRequiredKeyedService<T> (this IServiceProvider provider, object? serviceKey);
static member GetRequiredKeyedService : IServiceProvider * obj -> 'T
<Extension()>
Public Function GetRequiredKeyedService(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
A service object of type T
.
Exceptions
There is no service of type T
.
Applies to
.NET 9 (package-provided) und andere Versionen
Produkt | Versionen |
---|---|
.NET | 8 (package-provided), 9 (package-provided) |
.NET Framework | 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided) |
.NET Standard | 2.0 (package-provided), 2.1 (package-provided) |
Feedback zu .NET
.NET ist ein Open Source-Projekt. Wählen Sie einen Link aus, um Feedback zu geben: