Class RouteTemplateCollection
- Namespace
- Blazing.Mvvm.Components.Routing
- Assembly
- Blazing.Mvvm.dll
Represents a collection of route templates associated with a single ViewModel or keyed ViewModel.
public sealed class RouteTemplateCollectionInheritance
Remarks
When a Blazor component has multiple @page directives, this collection stores all route templates
and designates one as the primary route for simple navigation scenarios.
Properties
AllRoutes
Gets all route templates associated with this ViewModel.
public required List<RouteTemplate> AllRoutes { get; init; }Property Value
Remarks
This list contains parsed representations of all @page directives defined on the component.
The templates are used during navigation to select the best-matching route based on provided parameters.
Primary
Gets the RouteTemplate object corresponding to the PrimaryRoute pattern.
public RouteTemplate Primary { get; }Property Value
Remarks
This is a convenience property that retrieves the primary route's template from AllRoutes.
Exceptions
- InvalidOperationException
-
Thrown if the primary route pattern is not found in AllRoutes. This should never occur if the collection is properly initialized.
PrimaryRoute
Gets the primary route pattern used for simple navigation without parameters.
public required string PrimaryRoute { get; init; }Property Value
Examples
For a component with routes /test and /test/{echo},
the primary route would be /test.
Remarks
The primary route is typically the simplest route (one without parameters, or with the fewest parameters). It is used as the default when navigating to a ViewModel without specifying route parameters.