NavigationPath record

Namespace Runic.Navigation in Runic.Navigation 0.23.0

public sealed record NavigationPath : IEquatable<NavigationPath>

Inherits or implements IEquatable.

A serializable navigation state: the regions and selections of a navigator that no entry owns, each with its entries and, below each entry, the regions and selections its content owns. RunicNavigator.GetPath creates it and RunicNavigator.RestoreAsync rebuilds it, for example after a restart.

Parameters

Regions

The root regions, by position.

Selections

The root selections, by position.

Remarks

Regions and selections are recorded by position: the regions an owner created, in creation order, leaving out those of a selection, and its selections in creation order. An entry is recorded by its route (INavigationRouteMap). A path holds no entry ids, region keys or content, so it stays valid across processes as long as the application creates its regions in the same order.

Store it where the application keeps its own state, for example as JSON next to the window placement: NavigationPath.ToJson and NavigationPath.FromJson read and write a stable format without reflection.

Constructors

NavigationPath

public NavigationPath(IReadOnlyList<NavigationRegionPath> Regions, IReadOnlyList<NavigationSelectionPath> Selections)

A serializable navigation state: the regions and selections of a navigator that no entry owns, each with its entries and, below each entry, the regions and selections its content owns. RunicNavigator.GetPath creates it and RunicNavigator.RestoreAsync rebuilds it, for example after a restart.

Parameters

Regions

The root regions, by position.

Selections

The root selections, by position.

Remarks

Regions and selections are recorded by position: the regions an owner created, in creation order, leaving out those of a selection, and its selections in creation order. An entry is recorded by its route (INavigationRouteMap). A path holds no entry ids, region keys or content, so it stays valid across processes as long as the application creates its regions in the same order.

Store it where the application keeps its own state, for example as JSON next to the window placement: NavigationPath.ToJson and NavigationPath.FromJson read and write a stable format without reflection.

Fields

FormatVersion

public const int FormatVersion = 1

The version that NavigationPath.ToJson writes.

Properties

Empty

public static NavigationPath Empty { get; }

Gets an empty path: restoring it changes nothing.

Regions

public IReadOnlyList<NavigationRegionPath> Regions { get; init; }

The root regions, by position.

Selections

public IReadOnlyList<NavigationSelectionPath> Selections { get; init; }

The root selections, by position.

Methods

FromJson

public static NavigationPath FromJson(string json)

Reads a path that NavigationPath.ToJson wrote. Unknown properties are ignored.

Exceptions

FormatException

The text is not such a path, has a newer version, nests deeper than 32 levels or has more than 10,000 entries, regions and selections.

ToJson

public string ToJson()

Writes the path as JSON: {"version":1,"regions":[{"entries":[{"route":"customers","regions":[],"selections":[]}]}],"selections":[]}. An entry without a route has "route":null.