Click or drag to resize

ServiceHelperGetServiceT Method (IServiceProvider, Boolean)

Gets a service from a given service provider.

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

Parameters

serviceProvider
Type: SystemIServiceProvider
The service provider from which to obtain the service.
throwIfNotAvailable
Type: SystemBoolean
if this method should throw a ServiceNotAvailableException if the requested service is not available from the service provider, or if this method should simply return if the service does not exist.

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 throwIfNotAvailable is , and the requested service is not available from the service provider.
See Also