public static class RunicWindowHostExtensions Opens and validates Windows on any IRunicWindowHost.
Methods
OpenWindowAsync
public static ValueTask<TWindow> OpenWindowAsync<TWindow>(this IRunicWindowHost host, RunicWindowOptions? options = null, CancellationToken cancellationToken = default) where TWindow : class, IRunicWindow, new() Creates TWindow, resolves its ViewModel in a new DI scope, and opens it on host. Release the Window with await using.
Parameters
hostThe host, such as the one
RunicDesktopHost.Runpasses to the application.optionsThe content and size;
nullopenswww/index.htmlnext to the application.cancellationTokenCancels opening. A cancelled open releases everything it created.
Returns
The open Window.
Exceptions
RunicWindowConfigurationExceptionA check failed before anything opened, for example no generated Bridge is registered for the ViewModel (
RunicWindowConfigurationException.BridgeNotRegisteredCode), or the host rejected the window configuration.
OpenWindowAsync
public static ValueTask<TWindow> OpenWindowAsync<TWindow, TParameter>(this IRunicWindowHost host, TParameter parameter, RunicWindowOptions? options = null, CancellationToken cancellationToken = default) where TWindow : class, IRunicWindow, new() where TParameter : class Opens TWindow as RunicWindowHostExtensions.OpenWindowAsync does, and hands parameter to its new scope: the Window's ViewModel, and every service of that scope, takes IRunicWindowParameter in its constructor and reads it from there.
Parameters
hostThe host, such as the one
RunicDesktopHost.Runpasses to the application.parameterThe value the new Window's scope receives.
optionsThe content and size;
nullopenswww/index.htmlnext to the application.cancellationTokenCancels opening. A cancelled open releases everything it created.
Returns
The open Window.
Exceptions
RunicWindowConfigurationExceptionA check failed before anything opened, for example
RunicWindowServiceCollectionExtensions.AddRunicWindowServicewas not called (RunicWindowConfigurationException.WindowParameterNotRegisteredCode).
Remarks
await host.OpenWindowAsync<DocumentWindow, DocumentRequest>(new DocumentRequest(path));
public sealed class DocumentViewModel(IRunicWindowParameter<DocumentRequest> request) { ... }The parameter belongs to this Window only: another Window, opened at the same time, gets its own. It needs RunicWindowServiceCollectionExtensions.AddRunicWindowService in the application's services.
ValidateWindow
public static RunicWindowValidationResult ValidateWindow<TWindow>(this IRunicWindowHost host, RunicWindowOptions? options = null) where TWindow : class, IRunicWindow, new() Checks at startup, before any window opens, that host can open TWindow with options: the generated Bridge registration (an error when missing), the ViewModel registration (a warning when the container does not confirm it), and the host's own presentation checks.
Remarks
Registrations are checked through IServiceProviderIsService without constructing anything; containers without it are not checked here, and opening still reports a missing Bridge before any window exists. Errors are logged through the provider's ILoggerFactory (event 1050). Call RunicWindowValidationResult.ThrowIfInvalid to stop at startup.