logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class ViewRouter

    Default IViewRouter: shows a view by id by asking each registered IViewProvider in turn whether it owns the id, and delegating to the first that does. Engine-agnostic and unit-testable — it depends only on the provider abstraction and a log service.

    Inheritance
    object
    ViewRouter
    Implements
    IViewRouter
    IService
    IFoundationSettings
    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 class ViewRouter : IViewRouter, IService, IFoundationSettings

    Constructors

    ViewRouter(IEnumerable<IViewProvider>, ILogService)

    Creates the router over an ordered set of providers.

    Declaration
    public ViewRouter(IEnumerable<IViewProvider> providers, ILogService logService)
    Parameters
    Type Name Description
    IEnumerable<IViewProvider> providers

    The providers consulted, in priority order, to resolve a view id.

    ILogService logService

    Logging service.

    Properties

    Guid

    Declaration
    public string Guid { get; set; }
    Property Value
    Type Description
    string

    Id

    Declaration
    public string Id { get; set; }
    Property Value
    Type Description
    string

    LogService

    Declaration
    public ILogService LogService { get; set; }
    Property Value
    Type Description
    ILogService

    Gets or sets the log service for logging purposes.

    Methods

    HideView(string)

    Hides the view with the given id via whichever provider owns it.

    Declaration
    public void HideView(string viewId)
    Parameters
    Type Name Description
    string viewId

    The id of the view to hide.

    RegisterProvider(IViewProvider)

    Registers a provider (a subsystem that owns top-level views) consulted when resolving ids.

    Declaration
    public void RegisterProvider(IViewProvider provider)
    Parameters
    Type Name Description
    IViewProvider provider

    The provider to add.

    SetInitialViewId(string)

    Sets the id of the initial/root view shown by ShowInitialView().

    Declaration
    public void SetInitialViewId(string viewId)
    Parameters
    Type Name Description
    string viewId

    The initial view id (may be a menu or a custom view).

    ShowInitialView()

    Shows the configured initial/root view.

    Declaration
    public void ShowInitialView()

    ShowView(string)

    Shows the view with the given id via whichever provider owns it, first hiding the currently shown top-level view (if any and different). This is how navigation "deactivates the current view and activates the target" uniformly for menus and composite custom views.

    Declaration
    public void ShowView(string viewId)
    Parameters
    Type Name Description
    string viewId

    The id of the view to show.

    Implements

    IViewRouter
    IService
    IFoundationSettings
    In this article
    © 2026 Serenity. All Rights Reserved