NavigationRouteMapBuilder class

Namespace Runic.Navigation in Runic.Navigation 0.23.0

public sealed class NavigationRouteMapBuilder

Declares the routes of a NavigationRouteMap.

Remarks

Each Map method checks its template at once and throws ArgumentException for a malformed template, a parameter type the method can't pass, or a parameter declared twice.

Constructors

NavigationRouteMapBuilder

public NavigationRouteMapBuilder()

No documentation.

Methods

Build

public NavigationRouteMap Build()

Builds the map. The builder can be used again; later routes don't change a built map.

Map

public NavigationRouteMapBuilder Map<T>(string template) where T : class

Maps a template without parameters to NavigationTarget.Create. An entry whose content is exactly a T created without input has this route.

Type parameters

T

The content type the navigator constructs.

Parameters

template

The route template, such as customers.

Map

public NavigationRouteMapBuilder Map<T, TInput>(string template) where T : class, INavigationInput<TInput>

Maps a template with one parameter to NavigationTarget.Create, passing the parameter's value as the input. An entry whose content is exactly a T created with a TInput input has this route.

Type parameters

T

The content type the navigator constructs.

TInput

The parameter's type: Int32, Int64, String, Guid or Boolean, matching the template's constraint.

Parameters

template

The route template, such as customers/{id:int}.

Map

public NavigationRouteMapBuilder Map<T, TInput>(string template, Func<NavigationRouteValues, TInput> read, Func<TInput, NavigationRouteValues?> write) where T : class, INavigationInput<TInput>

Maps a template to NavigationTarget.Create with an input read from the parameters, such as a record of a customer and an invoice number. An entry whose content is exactly a T created with a TInput input has this route, with the parameters write gives.

Type parameters

T

The content type the navigator constructs.

TInput

The input type.

Parameters

template

The route template, such as customers/{id:int}/invoices/{invoice:int}.

read

Creates the input from the parameter values.

write

Gives the parameter values of an input, or null when the route doesn't describe it.

Map

public NavigationRouteMapBuilder Map<T>(string template, Func<IServiceProvider, NavigationRouteValues, INavigationTarget<T>?> target, Func<T, NavigationRouteValues?> values) where T : class

Maps a template to targets that target creates, such as a borrowed page from the window's services or a factory with a NavigationEntryContext. An entry whose content is a T has this route when values returns its parameter values.

Type parameters

T

The content type.

Parameters

template

The route template.

target

Creates the target from the navigator's RunicNavigator.Services (an empty provider without them) and the parameter values; it must not construct content (use a Create target) unless it borrows it. Return null to let a later route match.

values

Gives the parameter values of an entry's content, an empty NavigationRouteValues for a template without parameters, or null when the route doesn't describe it.