Click or drag to resize

ServiceHelperGetServiceT Method (IServiceProvider, String)

Gets a service from a given service provider, throwing a ServiceNotAvailableException if the service is not available.

Namespace:  AGI.Foundation.Infrastructure
Assembly:  AGI.Foundation.Core (in AGI.Foundation.Core.dll) Version: 24.2.419.0 (24.2.419.0)
Syntax
public static T GetService<T>(
	IServiceProvider serviceProvider,
	string exceptionMessage
)
where T : class

Parameters

serviceProvider
Type: SystemIServiceProvider
The service provider from which to obtain the service.
exceptionMessage
Type: SystemString
An error message to include in the exception if the service is unavailable.

Type Parameters

T
The type of service to obtain.

Return Value

Type: T
The requested service.
Exceptions
ExceptionCondition
ArgumentNullException Thrown when the serviceProvider is .
ServiceNotAvailableException Thrown when the requested service is not available from the service provider.
See Also