ServiceHelperLocateServiceT Method (Type, Object, IEnumerableT) |
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
.
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 Object LocateService<T>(
Type serviceType,
Object candidate,
IEnumerable<T> additionalServiceProviders
)
where T : IServiceProvider
Public Shared Function LocateService(Of T As IServiceProvider) (
serviceType As Type,
candidate As Object,
additionalServiceProviders As IEnumerable(Of T)
) As Object
public:
generic<typename T>
where T : IServiceProvider
static Object^ LocateService(
Type^ serviceType,
Object^ candidate,
IEnumerable<T>^ additionalServiceProviders
)
static member LocateService :
serviceType : Type *
candidate : Object *
additionalServiceProviders : IEnumerable<'T> -> Object when 'T : IServiceProvider
Parameters
- serviceType
- Type: SystemType
The type of the service that is requested.
- candidate
- Type: SystemObject
A candidate object that could be of the requested serviceType.
- additionalServiceProviders
- Type: System.Collections.GenericIEnumerableT
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:
ObjectThe requested service, or
if not found.
Exceptions Exception | Condition |
---|
ArgumentNullException |
Thrown when serviceType, candidate, or additionalServiceProviders is .
|
See Also