NavigationEntryContext class

Namespace Runic.Navigation · Runic.Navigation 0.7.0-preview.5

public sealed class NavigationEntryContext

Gives an entry's hooks its identity, retirement signal, model context and late-completion operations.

Properties

Id

public NavigationEntryId Id { get; }

Gets the entry's id.

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 INavigationEntry.Services returns. After an entry with its own scope retires, resolving from it throws ObjectDisposedException.

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

TResult

The request's result type, or any type whose value is a result-type value at run time, such as Boolean for a bool? request or Int32 for an Object request.

Parameters

result

The result.

cancellationToken

Cancels the back transition before it commits.

Exceptions

InvalidOperationException

The entry was not pushed with PushForResult, or result is 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:

Parameters

cancellationToken

Cancels the Back before it commits. The dismissal of the request is not undone.