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)
Syntaxpublic static Object LocateService<T>(
Type serviceType,
Object candidate,
params T[] additionalServiceProviders
)
where T : IServiceProvider
Public Shared Function LocateService(Of T As IServiceProvider) (
serviceType As Type,
candidate As Object,
ParamArray additionalServiceProviders As T()
) As Object
public:
generic<typename T>
where T : IServiceProvider
static Object^ LocateService(
Type^ serviceType,
Object^ candidate,
... array<T>^ additionalServiceProviders
)
static member LocateService :
serviceType : Type *
candidate : Object *
additionalServiceProviders : 'T[] -> Object when '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:
ObjectThe requested service, or
null if not found.
ExceptionsException | Condition |
---|
ArgumentNullException |
Thrown when serviceType, candidate, or additionalServiceProviders is null.
|
See Also