Class ServiceLocator
Inherited Members
Namespace: GigaCreation.Tools.Service
Assembly: GigaCreation.Tools.Service.dll
Syntax
public static class ServiceLocator
Methods
| Improve this Doc View SourceGet<TService>(bool)
Get a service.
Declaration
public static TService Get<TService>(bool includeDerivedType = false) where TService : class, IService
Parameters
Type | Name | Description |
---|---|---|
bool | includeDerivedType | If true, the search includes derived types. |
Returns
Type | Description |
---|---|
TService | The service of the requested type. |
Type Parameters
Name | Description |
---|---|
TService | The type of a service. |
IsRegistered<TService>(bool)
Checks if a service of the specified type is registered.
Declaration
public static bool IsRegistered<TService>(bool includeDerivedType = false) where TService : class, IService
Parameters
Type | Name | Description |
---|---|---|
bool | includeDerivedType | If true, the search includes derived types. |
Returns
Type | Description |
---|---|
bool | Returns true if a service of the given type is registered. |
Type Parameters
Name | Description |
---|---|
TService | The type of a service to check. |
IsRegistered<TService>(TService, bool)
Checks if the specified service is registered.
Declaration
public static bool IsRegistered<TService>(TService service, bool includeDerivedType = false) where TService : class, IService
Parameters
Type | Name | Description |
---|---|---|
TService | service | The service to check. |
bool | includeDerivedType | If true, the search includes derived types. |
Returns
Type | Description |
---|---|
bool | Returns true if the given service is registered. |
Type Parameters
Name | Description |
---|---|
TService | The type of a service to check. |
Register<TService>(TService)
Register a service. If a service of the same type is already registered, you should unregister it first.
Declaration
public static void Register<TService>(TService service) where TService : class, IService
Parameters
Type | Name | Description |
---|---|---|
TService | service | The service to register. |
Type Parameters
Name | Description |
---|---|
TService | The type of the service. |
TryGet<TService>(out TService, bool)
Try to get a service.
Declaration
public static bool TryGet<TService>(out TService service, bool includeDerivedType = false) where TService : class, IService
Parameters
Type | Name | Description |
---|---|---|
TService | service | The service of the requested type. |
bool | includeDerivedType | If true, the search includes derived types. |
Returns
Type | Description |
---|---|
bool | Returns true if the get was successful. |
Type Parameters
Name | Description |
---|---|
TService | The type of a service. |
UnregisterAsync<TService>(TService)
Unregister a service asynchronously.
Declaration
public static ValueTask UnregisterAsync<TService>(TService service) where TService : class, IService
Parameters
Type | Name | Description |
---|---|---|
TService | service | The service to unregister. |
Returns
Type | Description |
---|---|
ValueTask |
Type Parameters
Name | Description |
---|---|
TService | The type of the service. |
Unregister<TService>(TService)
Unregister a service.
Declaration
public static void Unregister<TService>(TService service) where TService : class, IService
Parameters
Type | Name | Description |
---|---|---|
TService | service | The service to unregister. |
Type Parameters
Name | Description |
---|---|
TService | The type of the service. |