IRunicWindowHost interface

Namespace Runic.Application.Views in Runic.Application.Views 0.23.0

public interface IRunicWindowHost

A host that opens application Windows: Runic Desktop (RunicDesktopHost) or CS-WebUI (RunicCsWebUiHost). Application code opens Windows with RunicWindowHostExtensions.OpenWindowAsync, which is the same on every host.

Remarks

Host adapters implement this interface; applications do not. The members other than IRunicWindowHost.Services are called by RunicWindowHostExtensions.

Properties

Services

IServiceProvider Services { get; }

The application's service provider. Each Window opens in a new scope of it.

Methods

OpenAsync

ValueTask<IBridgeWindow> OpenAsync<TViewModel>(RunicWindowOpening<TViewModel> opening, CancellationToken cancellationToken) where TViewModel : class

Presents a Window whose scope, ViewModel and Bridge RunicWindowHostExtensions.OpenWindowAsync has prepared. From this call the host owns RunicWindowOpening.Scope: it disposes it when the window closes, and before it throws.

OpenWindowAsync

ValueTask<TWindow> OpenWindowAsync<TWindow>(RunicWindowOptions? options, DesktopActivationContext? activation, CancellationToken cancellationToken = default) where TWindow : class, IRunicWindow, new()

Opens TWindow as RunicWindowHostExtensions.OpenWindowAsync does, and asks the desktop to give the new window focus with activation.

Parameters

options

The content and size; null opens www/index.html next to the application.

activation

The desktop's short-lived activation data, or null. Use it once, promptly.

cancellationToken

Cancels opening. A cancelled open releases everything it created.

Returns

The open Window.

Exceptions

RunicWindowConfigurationException

A check failed before anything opened.

Remarks

Open a Window for a launch with the launch's activation context, such as ApplicationLaunch.PlatformContext of a launch the running instance received: Wayland compositors such as KWin give a new window focus only with the activation token of the launch it answers. Runic Desktop presents its native window with the context; a host that cannot use it, such as CS-WebUI or a browser, opens the Window and ignores the context, as this default implementation does.

Validate

IReadOnlyList<RunicWindowDiagnostic> Validate(RunicWindowOptions options)

Checks, without opening anything, whether the host can present a window with options.