ServiceHelper.GetService<T> 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: 25.1.421.0 (25.1.421.0)
Syntaxpublic 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: System.IServiceProvider
The service provider from which to obtain the service. - throwIfNotAvailable
- Type: System.Boolean
true if this method should throw a ServiceNotAvailableException if
the requested service is not available from the service provider, or false if this
method should simply return null if the service does not exist.
Type Parameters
- T
- The type of service to obtain.
Return Value
Type:
TThe requested service.
Exceptions
See Also