RunicWindowOpening<TViewModel> class

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

public sealed class RunicWindowOpening<TViewModel> where TViewModel : class

A Window being opened, prepared for its host by RunicWindowHostExtensions.OpenWindowAsync.

Remarks

Host adapters use it; applications do not.

Properties

CloseGuard

public Func<CancellationToken, ValueTask<bool>>? CloseGuard { get; }

The Window's close guard, or null when RunicWindow.GuardClose is false.

Remarks

A host whose window can stay open calls it, after RunicWindowOpening.AttachBridge, when the user closes the window, and closes the window only when it returns true. It runs RunicWindow.CanCloseAsync in a model turn and never throws: a failure is logged and returns false, as cancellation does. A host that cannot keep its window open calls RunicWindowOpening.ReportCloseGuardUnavailable instead.

Options

public RunicWindowOptions Options { get; }

The validated options.

Scope

public AsyncServiceScope Scope { get; }

The Window's DI scope. The host owns it from IRunicWindowHost.OpenAsync on.

ViewModel

public TViewModel ViewModel { get; }

The Window's scoped root ViewModel, already assigned to the Window.

Window

public RunicWindow<TViewModel> Window { get; }

The application Window.

Methods

AttachBridge

public IDisposable AttachBridge(IBridgeTransport transport, WindowContentSession content)

Attaches the generated Bridge to transport. Dispose the result when the window closes.

ReportCloseDrainUnavailable

public void ReportCloseDrainUnavailable(string presentation)

Logs WindowCloseDrainUnavailable (event 1055): the Window has a close drain (RunicWindowOptions.CloseDrain), but presentation, such as CS-WebUI or a browser, cannot keep its window open, so the window closes at once and its work drains without it.

Parameters

presentation

The presentation that cannot keep the window open, as it reads in a sentence.

ReportCloseGuardUnavailable

public void ReportCloseGuardUnavailable(string presentation)

Logs WindowCloseGuardUnavailable (event 1053): the Window guards its close, but presentation, such as CS-WebUI, cannot keep its window open, so it opens unguarded.

Parameters

presentation

The presentation that cannot keep the window open, as it reads in a sentence.

ReportOwnerIgnored

public void ReportOwnerIgnored(string reason)

Logs WindowOwnerIgnored (event 1180): the host opens the Window without its RunicWindowOptions.Owner, for reason.

Parameters

reason

Why, as it reads in a sentence, such as CS-WebUI cannot own windows.

UseCloseRequest

public void UseCloseRequest(Func<CancellationToken, ValueTask<bool>> requestClose)

Makes RunicWindow.RequestCloseAsync call requestClose, the host's own request to close the window as the user's close button does.

Parameters

requestClose

Requests the close; its token stops only the caller's wait.

Remarks

A host whose user close asks RunicWindowOpening.CloseGuard or another confirmation passes its close request, so a request and a user close share one decision. It returns whether the window closed, and true once the window is closed. Without it, RequestCloseAsync asks RunicWindowOpening.CloseGuard itself and then closes the window with IBridgeWindow.CloseAsync.

UsePresentation

public void UsePresentation(IRunicWindowPresentation presentation)

Gives the Window's IRunicWindowPresentation the host's own: the window's scope and IRunicWindow.Presentation forward their requests to it from now on, and raise its activity changes in the Window's model turns.

Parameters

presentation

The host's presentation of this window.

Exceptions

InvalidOperationException

The Window already has a presentation.

Remarks

Call it once the native window exists, after RunicWindowOpening.AttachBridge. A host without a native window, such as one that only serves the page, does not call it: requests then report PlatformUnavailableReason.OwnerUnavailable. The host's presentation may raise its events on any thread.