Table of Contents

Class ViewModelRouteCache

Namespace
Blazing.Mvvm.Components.Routing
Assembly
Blazing.Mvvm.dll

Provides a singleton cache for mapping ViewModel types and keys to their associated route URIs in a Blazor MVVM application.

public sealed class ViewModelRouteCache : IViewModelRouteCache

Inheritance

Implements

Remarks

This cache is used to efficiently resolve navigation routes for ViewModels and keyed ViewModels, supporting both type-based and key-based navigation.

Constructors

ViewModelRouteCache(ILogger<ViewModelRouteCache>, LibraryConfiguration)

Initializes a new instance of the ViewModelRouteCache class, sets up logging and configuration, and generates the reference cache.

public ViewModelRouteCache(ILogger<ViewModelRouteCache> logger, LibraryConfiguration configuration)

Parameters

logger ILogger<ViewModelRouteCache>

The logger used for diagnostic messages.

configuration LibraryConfiguration

The library configuration containing assemblies and base path.

Properties

KeyedViewModelRouteTemplates

Gets the cached route template collections for keyed ViewModels, mapping navigation keys to RouteTemplateCollection.

public IReadOnlyDictionary<object, RouteTemplateCollection> KeyedViewModelRouteTemplates { get; }

Property Value

IReadOnlyDictionary<object, RouteTemplateCollection>

Remarks

This property supports multi-route template navigation for keyed ViewModels, enabling components registered with a navigation key to define multiple route patterns.

Similar to ViewModelRouteTemplates, this allows smart route selection based on the navigation parameters provided when navigating by key.

KeyedViewModelRoutes

Gets the cached routes for keyed ViewModels, mapping navigation keys to route URI String.

public IReadOnlyDictionary<object, string> KeyedViewModelRoutes { get; }

Property Value

IReadOnlyDictionary<object, string>

ViewModelRouteTemplates

Gets the cached route template collections for ViewModels, mapping ViewModel Type to RouteTemplateCollection.

public IReadOnlyDictionary<Type, RouteTemplateCollection> ViewModelRouteTemplates { get; }

Property Value

IReadOnlyDictionary<Type, RouteTemplateCollection>

Remarks

This property supports multi-route template navigation, allowing ViewModels with multiple @page directives to have all their route templates cached and available for smart template selection during navigation.

When a component has multiple routes (e.g., @page "/test" and @page "/test/{echo}"), the collection contains all parsed templates along with metadata to select the most appropriate route based on the navigation parameters provided.

ViewModelRoutes

Gets the cached routes for ViewModels, mapping ViewModel Type to route URI String.

public IReadOnlyDictionary<Type, string> ViewModelRoutes { get; }

Property Value

IReadOnlyDictionary<Type, string>