public sealed class WindowContentSession : IDisposable Routes the content ViewModels of one window to their browser presentations. The window owns this session and the application or DI scope continues to own the ViewModels.
Constructors
WindowContentSession
public WindowContentSession(IBridgeTransport transport) Creates the content session for one window with the default options.
Parameters
transportThe window's host transport.
WindowContentSession
public WindowContentSession(IBridgeTransport transport, WindowContentSessionOptions options) Creates the content session for one window.
Parameters
transportThe window's host transport.
optionsThe session's View locator, model context, logging, clock and id source.
Properties
AcceptsFileDrops
public bool AcceptsFileDrops { get; } Gets whether the window's root ViewModel receives dropped files (IRunicFileDropTarget).
Appearance
public DesktopAppearance? Appearance { get; set; } The window's appearance: the desktop preferences its host read, such as the colour scheme, the contrast preference and its forced-colours palette, reduced motion, the text scale and the accent colour; or null while the host reads none. Setting it pushes it to the window's pages (feature appearance/1), whose appearance store reports what their engine's media queries do not; a page that connects later receives it after its hello. It can be set from any thread.
Remarks
RunicDesktopHost sets it on every window it opens from IDesktopSettings, and keeps it current while the window is open. A test sets it directly. Setting an equal value pushes nothing.
Interactions
public BridgeInteractionRouter Interactions { get; } Window-owned interaction request router used by optional UI adapters.
Locale
public string? Locale { get; set; } The window's locale, a BCP 47 tag such as de or pt-BR, or null while the application sets none and each page keeps its own. Setting it pushes it to the window's pages (feature translation-text/1), which show text references, such as validation messages, in that language and set the locale of their Translations runtime; a page that connects later receives it after its hello. It can be set from any thread.
Exceptions
ArgumentExceptionThe value is not 1 to 64 letters, digits and
-, starting with a letter.
Remarks
A ViewModel of a Window that OpenWindowAsync opened sets it through IRunicWindowLocale; a value set here directly is that Window's own locale, and null makes it follow the application's IRunicApplicationLocale again, which this property then shows. Otherwise, setting null after a locale leaves the pages in the language they show.
ModelContext
public IRunicModelContext? ModelContext { get; } Gets the execution context shared by this window's ViewModel graph. A model already owned by an application-wide graph keeps that existing context when another window attaches to it.
Methods
AttachPresentation
public IDisposable AttachPresentation<TView, TViewModel>(TViewModel viewModel, string route, Func<IBridgeTransport, TViewModel, string, IDisposable> attachBridge, string? contract = null) where TView : class, IRunicView where TViewModel : class Attaches one route Bridge while resolving a fresh logical View for every mounted web presentation. The ViewModel remains application-owned; each mounted View owns only its own attached, mounted, and disposable lifetime.
AttachPresentation
public IDisposable AttachPresentation<TView, TViewModel>(TViewModel viewModel, string route, Func<IBridgeTransport, TViewModel, string, IDisposable> attachBridge, Func<TView> createView) where TView : class, IRunicView where TViewModel : class Variant for an application-owned factory. It must produce a distinct View for concurrently mounted presentations. Returning one already mounted View is rejected with an ownership error.
AttachRootInteractionPresentation
public IDisposable AttachRootInteractionPresentation(string route) Keeps the presentations that pages open on a root route which exposes interactions until the returned lease is disposed, which closes them. Every root route registers the presentations of open requests; content routes own theirs with their content.
Parameters
routeThe root route.
Returns
A lease that closes the route's presentations.
Clear
public void Clear(object owner, string property) Clears the content presented for property of owner.
ClearOwner
public void ClearOwner(object owner) Releases every content slot of a parent. Generated parent bridges call this from their own disposal, including while the window disposes, so it is a no-op after the session was disposed.
DeliverFileDropAsync
public ValueTask DeliverFileDropAsync(RunicFileDrop drop, CancellationToken cancellationToken) Passes files dropped onto the window's native presentation to the root ViewModel, when it implements IRunicFileDropTarget, in its model turn. Host adapters call it once per drop, in drop order.
Parameters
dropThe drop, with paths from the native window.
cancellationTokenCancelled when the window closes.
Returns
A task that completes when the ViewModel has handled the drop. It never faults: a failure is logged (event 1054).
Dispose
public void Dispose() Detaches all presented content, removes the window's routes and releases its model-context leases.
DrainAsync
public ValueTask<RunicWindowCloseResult> DrainAsync(TimeSpan timeout, CancellationToken cancellationToken = default) Stops new window-owned operation admission, including awaited command routes, and waits up to timeout for accepted work to reach a terminal result. Work still running at the timeout is asked to cancel; call again to wait for it. Content, fields, and routes owned by this session stay intact until the owner later disposes the session.
Parameters
timeoutHow long to wait for accepted work, or
Timeout.InfiniteTimeSpan.cancellationTokenStops this caller's wait. Admission stays stopped and accepted work keeps running.
Exceptions
ArgumentOutOfRangeExceptiontimeoutis negative and not infinite.OperationCanceledExceptioncancellationTokenwas cancelled.
Remarks
The first call also tells the window's pages that it closes: each connection that uses presented/1 receives closing, and the call waits, at the same time as for accepted work and at most timeout or 5 seconds, until each such page answered or disconnected. RunicWindowCloseResult.PagesAcknowledged reports whether they all did. With TimeSpan.Zero the pages are told but not waited for. Later calls reuse the first call's result.
The result's RunicWindowCloseResult.Completion completes when the remaining operations reach a terminal result. It never faults; the session itself stays alive until its owner disposes it.
Operations declared RunicOperationClose.Cancel are asked to cancel when the first call starts. Those declared RunicOperationClose.Durable, and the work of the scopes the Window drains (IRunicWindowContext.DrainOnClose) accepted before the first call, are waited for within the timeout and never asked to cancel; the result counts them in RunicWindowCloseResult.RemainingDurableWork. Without declarations, the session closes as before 0.19.
Present
public PageReference Present<T>(object owner, string property, string kind, T viewModel, Func<IBridgeTransport, T, string, IDisposable> attach) where T : class Presents a ViewModel in one content property. Replacing or clearing the property suspends its old endpoint only if no other property in this window still presents that same object.
PresentItem
public PageReference PresentItem<T>(object owner, string property, string kind, T viewModel, Func<IBridgeTransport, T, string, IDisposable> attach) where T : class Retains a collection item by ViewModel identity, so reordering does not detach its route.
PruneCollection
public void PruneCollection(object owner, string property, IReadOnlySet<string> activeIds) Releases collection items omitted by the latest published snapshot.
ReleaseConnection
public void ReleaseConnection(string connectionKey) Releases only mounts owned by a disconnected host client.
Events
LocaleChanged
public event EventHandler? LocaleChanged Raised on the setting thread after WindowContentSession.Locale changed.