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
Public Shared Function GetService(Of T As Class) (
serviceProvider As IServiceProvider,
throwIfNotAvailable As Boolean
) As T
public:
generic<typename T>
where T : ref class
static T GetService(
IServiceProvider^ serviceProvider,
bool throwIfNotAvailable
)
static member GetService :
serviceProvider : IServiceProvider *
throwIfNotAvailable : bool -> 'T when 'T : not struct
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:
TThe requested service.
Exceptions See Also