Table of Contents

Class MvvmNavigationManager

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

Manages navigation via ViewModel using the route cache, supporting both type-based and key-based navigation in Blazor MVVM applications.

public class MvvmNavigationManager : IMvvmNavigationManager

Inheritance

Implements

Constructors

MvvmNavigationManager(NavigationManager, ILogger<MvvmNavigationManager>, IViewModelRouteCache, IOptions<LibraryConfiguration>, RouteTemplateSelector)

Initializes a new instance of the MvvmNavigationManager class.

public MvvmNavigationManager(NavigationManager navigationManager, ILogger<MvvmNavigationManager> logger, IViewModelRouteCache routeCache, IOptions<LibraryConfiguration> libraryConfiguration, RouteTemplateSelector routeTemplateSelector)

Parameters

navigationManager NavigationManager

The Blazor navigation manager for handling browser navigation.

logger ILogger<MvvmNavigationManager>

The logger for diagnostic information.

routeCache IViewModelRouteCache

The ViewModel route cache containing cached ViewModel-to-route mappings.

libraryConfiguration IOptions<LibraryConfiguration>

The library configuration containing base path and other settings.

routeTemplateSelector RouteTemplateSelector

The route template selector for choosing the best route template based on parameters.

Methods

GetUri<TViewModel>()

Gets the URI associated with the specified TViewModel.

public string GetUri<TViewModel>() where TViewModel : IViewModelBase

Returns

string

A relative URI path for navigation.

Type Parameters

TViewModel

The type implementing IViewModelBase to determine the navigation URI.

Exceptions

ArgumentException

Thrown when the ViewModel type has no associated route.

GetUri(object)

Gets the URI associated with the specified key.

public string GetUri(object key)

Parameters

key object

The key used to determine the navigation URI.

Returns

string

A relative URI path for navigation.

Exceptions

ArgumentNullException

Thrown when key is null.

NavigateTo<TViewModel>(bool, bool)

Navigates to the URI associated with the specified TViewModel.

public void NavigateTo<TViewModel>(bool forceLoad = false, bool replace = false) where TViewModel : IViewModelBase

Parameters

forceLoad bool

If true, bypasses client-side routing and forces the browser to load the new page from the server.

replace bool

If true, replaces the current entry in the history stack; otherwise, appends a new entry.

Type Parameters

TViewModel

The type implementing IViewModelBase to determine the navigation URI.

NavigateTo<TViewModel>(BrowserNavigationOptions)

Navigates to the URI associated with the specified TViewModel using browser navigation options.

public void NavigateTo<TViewModel>(BrowserNavigationOptions options) where TViewModel : IViewModelBase

Parameters

options BrowserNavigationOptions

Additional BrowserNavigationOptions for navigation.

Type Parameters

TViewModel

The type implementing IViewModelBase to determine the navigation URI.

NavigateTo<TViewModel>(string, bool, bool)

Navigates to the URI associated with the specified TViewModel, appending a relative URI or query string.

public void NavigateTo<TViewModel>(string relativeUri, bool forceLoad = false, bool replace = false) where TViewModel : IViewModelBase

Parameters

relativeUri string

The relative URI or query string to append.

forceLoad bool

If true, bypasses client-side routing and forces the browser to load the new page from the server.

replace bool

If true, replaces the current entry in the history stack.

Type Parameters

TViewModel

The type implementing IViewModelBase to determine the navigation URI.

Exceptions

ArgumentNullException

Thrown when relativeUri is null.

NavigateTo<TViewModel>(string, BrowserNavigationOptions)

Navigates to the URI associated with the specified TViewModel, appending a relative URI or query string and using browser navigation options.

public void NavigateTo<TViewModel>(string relativeUri, BrowserNavigationOptions options) where TViewModel : IViewModelBase

Parameters

relativeUri string

The relative URI or query string to append.

options BrowserNavigationOptions

Additional BrowserNavigationOptions for navigation.

Type Parameters

TViewModel

The type implementing IViewModelBase to determine the navigation URI.

Exceptions

ArgumentNullException

Thrown when relativeUri is null.

NavigateTo(object, bool, bool)

Navigates to the URI associated with the specified key.

public void NavigateTo(object key, bool forceLoad = false, bool replace = false)

Parameters

key object

The key used to determine the navigation URI.

forceLoad bool

If true, bypasses client-side routing and forces the browser to load the new page from the server.

replace bool

If true, replaces the current entry in the history stack.

Exceptions

ArgumentNullException

Thrown when key is null.

NavigateTo(object, BrowserNavigationOptions)

Navigates to the URI associated with the specified key using browser navigation options.

public void NavigateTo(object key, BrowserNavigationOptions options)

Parameters

key object

The key used to determine the navigation URI.

options BrowserNavigationOptions

Additional BrowserNavigationOptions for navigation.

Exceptions

ArgumentNullException

Thrown when key is null.

NavigateTo(object, string, bool, bool)

Navigates to the URI associated with the specified key, appending a relative URI or query string.

public void NavigateTo(object key, string relativeUri, bool forceLoad = false, bool replace = false)

Parameters

key object

The key used to determine the navigation URI.

relativeUri string

The relative URI or query string to append.

forceLoad bool

If true, bypasses client-side routing and forces the browser to load the new page from the server.

replace bool

If true, replaces the current entry in the history stack.

Exceptions

ArgumentNullException

Thrown when key or relativeUri is null.

NavigateTo(object, string, BrowserNavigationOptions)

Navigates to the URI associated with the specified key, appending a relative URI or query string and using browser navigation options.

public void NavigateTo(object key, string relativeUri, BrowserNavigationOptions options)

Parameters

key object

The key used to determine the navigation URI.

relativeUri string

The relative URI or query string to append.

options BrowserNavigationOptions

Additional BrowserNavigationOptions for navigation.

Exceptions

ArgumentNullException

Thrown when key or relativeUri is null.