Click or drag to resize

ServiceHelper.GetOptionalService<T> Method

Gets a service from a given service provider, or null if the service does not exist.

Namespace:  AGI.Foundation.Infrastructure
Assembly:  AGI.Foundation.Core (in AGI.Foundation.Core.dll) Version: 25.1.421.0 (25.1.421.0)
Syntax
public static T GetOptionalService<T>(
	IServiceProvider serviceProvider
)
where T : class

Parameters

serviceProvider
Type: System.IServiceProvider
The service provider from which to obtain the service.

Type Parameters

T
The type of service to obtain.

Return Value

Type: T
The requested service, or null if the service does not exist.
Exceptions
ExceptionCondition
ArgumentNullException Thrown when the serviceProvider is null.
See Also