RunicWpfNavigationServiceCollectionExtensions class

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

public static class RunicWpfNavigationServiceCollectionExtensions

Registers window navigation on the WPF dispatcher.

Methods

AddRunicWpfNavigation

public static IServiceCollection AddRunicWpfNavigation(this IServiceCollection services, Action<RunicWpfNavigationOptions>? configure = null)

Adds RunicNavigationServiceCollectionExtensions.AddRunicNavigation, then replaces the model context with one singleton DispatcherModelContext and the navigator with one of RunicWpfNavigationOptions.NavigatorLifetime. With RunicWpfNavigationOptions.MapView or RunicWpfNavigationOptions.UseViewNamingConvention, it also registers a singleton INavigationViewLocator, replacing an earlier one.

Parameters

services

The service collection.

configure

Configures the options.

Returns

services.

Exceptions

ArgumentException

The navigator lifetime is ServiceLifetime.Transient, or it is ServiceLifetime.Scoped with RunicWpfNavigationOptions.CreateEntryScopes set.

Remarks

The package assumes one UI thread. Without a configured RunicWpfNavigationOptions.Dispatcher and without Application.Current, resolving the model context throws InvalidOperationException. Dispose the provider asynchronously after the dispatcher stops; a synchronous dispose starts the navigator's disposal without waiting for it.