logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class ServiceLocatorBridge

    Static access bridge for the IServiceLocator instance.

    Inheritance
    object
    ServiceLocatorBridge
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    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; null otherwise.

    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; null otherwise.

    Returns
    Type Description
    bool

    true if a locator is set and the service is registered on it; otherwise, false.

    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.

    In this article
    © 2026 Serenity. All Rights Reserved