public sealed class NavigationEntryContext Gives an entry's content its identity, state, retirement signal, model context and late-completion operations.
Remarks
Content that the navigator creates takes its context as a constructor parameter: with NavigationTarget.Create and the region methods that wrap it, or from the factory of NavigationTarget.Create; the typed-input forms and initial targets included. Only the content receives it: a service resolved from the container can't, and resolving it there fails. Content created with NavigationTarget.Own or NavigationTarget.Borrow receives it in INavigationInitialize.InitializeAsync.
Properties
ModelContext
public IRunicModelContext ModelContext { get; } Gets the model context that commits navigation state.
Retirement
public CancellationToken Retirement { get; } Gets a token that is cancelled when the entry starts retiring.
Services
public IServiceProvider Services { get; } Gets the entry's service provider: its own service scope when the navigator created one (RunicNavigatorOptions.CreateEntryScopes), otherwise the navigator's RunicNavigator.Services, otherwise an empty provider. It is the provider NavigationEntry.Services returns. After an entry with its own scope retires, resolving from it throws ObjectDisposedException.
State
public NavigationEntryState State { get; } Gets the entry's current state. It is NavigationEntryState.Pending while the content is constructed and initialized, and changes in the model turn that commits a change (see NavigationEntryContext.StateChanged).
Methods
BackAsync
public ValueTask<NavigationResult<object>> BackAsync(CancellationToken cancellationToken = default) Goes back from this entry. The request expects this entry to be current, so a retained or retired entry receives NavigationRejection.NotCurrent.
CompleteAsync
public ValueTask<NavigationResult<object>> CompleteAsync<TResult>(TResult result, CancellationToken cancellationToken = default) Completes the NavigationRegion.PushForResult request that pushed this entry and goes back from it, like NavigationEntryContext.BackAsync. When this entry is the region's only entry, going back leaves the region empty. The request's completion becomes Completed with result only if that back transition commits; otherwise the entry stays current, the request stays open, and the call can be repeated. When the request was already dismissed, the entry still goes back and the result is dropped.
Type parameters
TResultThe request's result type, or any type whose value is a result-type value at run time, such as
Booleanfor abool?request orInt32for anObjectrequest.
Parameters
resultThe result.
cancellationTokenCancels the back transition before it commits.
Exceptions
InvalidOperationExceptionThe entry was not pushed with
PushForResult, orresultis not a value of its result type.
DismissAsync
public ValueTask<NavigationResult<object>> DismissAsync(CancellationToken cancellationToken = default) Leaves this entry without a result. What happens depends on the entry's state:
- Current, pushed with
NavigationRegion.PushForResult: the request endsDismissedat once, then the entry goes back likeNavigationEntryContext.CompleteAsync, which may leave the region empty. This is the path of a cancelled caller token: if that Back is rejected, the request stays dismissed and the entry stays. - Current, without an open result request: goes back from the entry, which may leave the region empty.
- Pending, because the push that creates it has not committed (for example, called from its own
INavigationInitialize.InitializeAsync): dismisses its request, cancels that push, which endsNavigationRejection.Cancelled, and returns that rejection at once without awaiting the push. The hook's token is cancelled. - Retained: dismisses its request and leaves the entry in place. Returns
NavigationRejection.NotCurrent. - Retiring or retired: does nothing. Returns
NavigationRejection.NotCurrent.
Parameters
cancellationTokenCancels the Back before it commits. The dismissal of the request is not undone.
Events
StateChanged
public event EventHandler<NavigationEntryStateChangedEventArgs>? StateChanged Raised once for each change of NavigationEntryContext.State, inside a model turn: the commit turn of a navigation; the turn that clears the entry's region when it closes; and, for a pending entry whose transition did not commit, a turn posted when it retires. When an initial target becomes current, RunicNavigator.CreateRegion raises it before it returns, on the caller's thread. A change that happens after the model context closed is not raised.
Remarks
In the commit turn it is raised after the new navigation state is applied and before the regions raise PropertyChanged, together with INavigationAware (see there for the order). Each handler is called separately; one that throws is logged (event 1075) and does not skip the others or undo the change.