Click or drag to resize

ServiceHelper.LocateService<T> Method (Type, Object,T[])

Convenience method for implementing IServiceProvider objects. If candidate is an instance of serviceType, returns candidate. Otherwise, checks additional IServiceProvider objects for any that return a non-null result for serviceType. Otherwise, returns null.

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 Object LocateService<T>(
	Type serviceType,
	Object candidate,
	params T[] additionalServiceProviders
)
where T : IServiceProvider

Parameters

serviceType
Type: System.Type
The type of the service that is requested.
candidate
Type: System.Object
A candidate object that could be of the requested serviceType.
additionalServiceProviders
Type:T[]
Additional service providers that will be checked, in order, for the requested service. The first non-null result will be returned.

Type Parameters

T
The type of additional service providers to search.

Return Value

Type: Object
The requested service, or null if not found.
Exceptions
ExceptionCondition
ArgumentNullException Thrown when serviceType, candidate, or additionalServiceProviders is null.
See Also