Class ServiceLocatorBridge
Static access bridge for the IServiceLocator instance.
Inherited Members
Namespace: Serenity.Global.Application.Services
Assembly: Serenity.Global.Application.dll
Syntax
public static class ServiceLocatorBridge
Remarks
Used by Unity-side components that cannot receive IServiceLocator via constructor injection, such as EventDispatcher actions instantiated via reflection. This bridge must be initialized during the installation flow via SetStatic(IServiceLocator).
Methods
ClearStatic()
Clears the current service locator instance.
Declaration
public static void ClearStatic()
SetStatic(IServiceLocator)
Sets the service locator instance.
Declaration
public static void SetStatic(IServiceLocator serviceLocator)
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceLocator | serviceLocator | The service locator to set. |
TryGetLogService()
Attempts to retrieve the log service through the current locator.
Declaration
public static ILogService TryGetLogService()
Returns
| Type | Description |
|---|---|
| ILogService | The log service if a locator is set and it is registered; |
Remarks
Composition-edge only. If the caller can take a constructor parameter, take one.
TryGetStatic(out IServiceLocator)
Attempts to retrieve the current service locator.
Declaration
public static bool TryGetStatic(out IServiceLocator serviceLocator)
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceLocator | serviceLocator | The service locator if available, null otherwise. |
Returns
| Type | Description |
|---|---|
| bool | True if a service locator is available, false otherwise. |
TryGet<TService>(out TService)
Resolves a service in one step through the current locator.
Declaration
public static bool TryGet<TService>(out TService service) where TService : class
Parameters
| Type | Name | Description |
|---|---|---|
| TService | service | The service instance if found; |
Returns
| Type | Description |
|---|---|
| bool |
|
Type Parameters
| Name | Description |
|---|---|
| TService | The type of the service to retrieve. |
Remarks
Composition-edge only. If the caller can take a constructor parameter, take one.