logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class OptionalServiceGate

    One consumer's defined behaviour for a service an OptionalModule publishes and that may never have installed: resolving answers false instead of throwing, and the first miss writes one warning that names the missing module, the feature that stays inactive, and the task that installs the module.

    Inheritance
    object
    OptionalServiceGate
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    Namespace: Serenity.Global.Application.Services
    Assembly: Serenity.Global.Application.dll
    Syntax
    public sealed class OptionalServiceGate
    Remarks

    Each consumer owns its own gate, so two features that both lose the same module each say so once. The warning is only spent when a log service is there to receive it: a miss before logging is installed does not silence the report the author would otherwise read later.

    Constructors

    OptionalServiceGate(OptionalModule, string)

    Creates the gate for one feature that depends on module.

    Declaration
    public OptionalServiceGate(OptionalModule module, string inactiveFeature)
    Parameters
    Type Name Description
    OptionalModule module

    The optional module that publishes the service.

    string inactiveFeature

    What stays inactive without it, in the author's terms (e.g. "The Save Game action").

    Properties

    MissingServiceMessage

    The warning written the first time the service is missing.

    Declaration
    public string MissingServiceMessage { get; }
    Property Value
    Type Description
    string

    Module

    The optional module this gate watches.

    Declaration
    public OptionalModule Module { get; }
    Property Value
    Type Description
    OptionalModule

    Methods

    ReportMissingOnce(ILogService, string)

    Writes MissingServiceMessage the first time it is called with a log service.

    Declaration
    public void ReportMissingOnce(ILogService logService, string logCategory)
    Parameters
    Type Name Description
    ILogService logService

    Where the absence is reported; null reports nothing and keeps the report pending.

    string logCategory

    The category the warning is written under.

    TryResolveThroughBridge<TService>(string, out TService)

    Resolves the service through ServiceLocatorBridge, reporting its absence once through the bridge's log service. Composition-edge only: for reflection-instantiated actions and Unity-constructed components that cannot take the locator as a parameter.

    Declaration
    public bool TryResolveThroughBridge<TService>(string logCategory, out TService service) where TService : class
    Parameters
    Type Name Description
    string logCategory

    The category the warning is written under.

    TService service

    The resolved service, or null.

    Returns
    Type Description
    bool

    true when the service is installed.

    Type Parameters
    Name Description
    TService

    The service contract to resolve.

    TryResolve<TService>(IServiceLocator, ILogService, string, out TService)

    Resolves the service from serviceLocator, reporting its absence once.

    Declaration
    public bool TryResolve<TService>(IServiceLocator serviceLocator, ILogService logService, string logCategory, out TService service) where TService : class
    Parameters
    Type Name Description
    IServiceLocator serviceLocator

    The locator to read from; null counts as the service being missing.

    ILogService logService

    Where the absence is reported; null reports nothing.

    string logCategory

    The category the warning is written under.

    TService service

    The resolved service, or null.

    Returns
    Type Description
    bool

    true when the service is installed.

    Type Parameters
    Name Description
    TService

    The service contract to resolve.

    In this article
    © 2026 Serenity. All Rights Reserved