RunicModelContextRegistry class

Namespace Runic.Navigation in Runic.Navigation 0.23.0

public sealed class RunicModelContextRegistry

Associates each model identity with the context that owns its mutations.

Remarks

A window session binds its root ViewModel and the content it presents, and a navigator binds the content it owns, each for as long as it presents or owns it. Bind other objects that must keep a context while nothing presents them. A second context for the same object is rejected rather than moving a live ViewModel between execution owners.

Properties

Shared

public static RunicModelContextRegistry Shared { get; }

Gets the process-wide registry used by generated bridges and content sessions.

Methods

Acquire

public IRunicModelContextLease Acquire(Func<IRunicModelContext> createContext, params object[] models)

Acquires a context for the supplied model graph. The first lease creates and owns it; later leases for the same graph reuse that context. It is disposed after the final owner lease is released.

Bind

public IRunicModelContextLease Bind(IRunicModelContext context, params object[] models)

Binds the supplied model identities to an application-owned context. Releasing this lease only removes registrations; it never disposes the supplied context.

GetRequired

public IRunicModelContext GetRequired(object model)

Gets the registered context for a model identity.

TryGet

public bool TryGet(object model, out IRunicModelContext? context)

Gets the registered context for a model identity.