ServiceExtensions Class
Definition
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.
Provides extension methods to retrieve proffered services synchronously from IServiceProvider and asynchronously from IAsyncServiceProvider.
public ref class ServiceExtensions abstract sealed
public static class ServiceExtensions
type ServiceExtensions = class
Public Module ServiceExtensions
- Inheritance
-
ServiceExtensions
Remarks
Prefer IAsyncServiceProvider3 and this class over using IServiceProvider, IAsyncServiceProvider and IAsyncServiceProvider2 directly to avoid unexpected blocking RPC calls when casting the resulting service to a specific interface. The former also provide more consistent throwing behavior.
Methods
GetService<TService,TInterface>(IServiceProvider, Boolean) |
Retrieves a proffered service synchronously, specifying whether to throw an exception if it could not be retrieved. |
GetService<TService,TInterface>(IServiceProvider) |
Retrieves a proffered service synchronously, throwing an exception if it could not be retrieved. |
GetServiceAsync<TService,TInterface>(IAsyncServiceProvider, Boolean, CancellationToken) |
Retrieves a proffered service asynchronously, specifying whether to throw an exception if it could not be retrieved. |
GetServiceAsync<TService,TInterface>(IAsyncServiceProvider, Boolean) |
Retrieves a proffered service asynchronously, specifying whether to throw an exception if it could not be retrieved. |
GetServiceAsync<TService,TInterface>(IAsyncServiceProvider, CancellationToken) |
Retrieves a proffered service asynchronously, throwing an exception if it could not be retrieved. |
GetServiceAsync<TService,TInterface>(IAsyncServiceProvider) |
Retrieves a proffered service asynchronously, throwing an exception if it could not be retrieved. |