DesktopBridgeWindowExtensions class

Namespace Runic.Application.Views.Desktop · Runic.Application.Desktop 0.7.0-preview.5

public static class DesktopBridgeWindowExtensions

Opens Desktop Views windows from a service provider.

Methods

OpenDesktopWindowAsync

public static ValueTask<TWindow> OpenDesktopWindowAsync<TWindow, TViewModel>(this IServiceProvider services, DesktopHost desktop, DesktopSurfaceOptions surfaceOptions, Func<DesktopBridgeWindow<TViewModel>, TWindow> createWindow, DesktopWindowOptions? windowOptions = null, CancellationToken cancellationToken = default) where TWindow : RunicWindow<TViewModel>, IAsyncDisposable where TViewModel : class

Creates an application Window in a new scope, then opens its Desktop presentation.

Remarks

When the RUNIC_APPLICATION_CLOSE_AFTER_OPEN environment variable is 1, every window opened through this method is closed as soon as it has opened (and, with DesktopHostOptions.WaitForConnection, its bridge has connected). Before closing, a warning is written to standard error (and logged as event 2002 when an ILoggerFactory is registered) and RUNIC_APPLICATION_OPENED=<presentation>, such as Embedded or Chrome, is written to standard output. It is an automation switch for applications shaped like the runic-app template, which exit when their one window's DesktopWindow.WaitForClose returns; other applications may keep running or reopen windows.

ValidateDesktopWindow

public static DesktopValidationResult ValidateDesktopWindow<TViewModel>(this IServiceProvider services, DesktopHost desktop, DesktopWindowOptions? windowOptions = null) where TViewModel : class

Checks at startup, before any window opens, that services can open a Window for TViewModel and that desktop can present it with windowOptions.

Remarks

The result combines the generated Bridge registration (an error when missing) and the ViewModel registration (a warning when the container does not confirm it through IServiceProviderIsService; containers without that service are not checked) with DesktopHost.Validate. Registration failures are logged through the service provider's ILoggerFactory. Call DesktopValidationResult.ThrowIfInvalid to stop at startup.