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 : IMvvmNavigationManagerInheritance
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
navigationManagerNavigationManager-
The Blazor navigation manager for handling browser navigation.
loggerILogger<MvvmNavigationManager>-
The logger for diagnostic information.
routeCacheIViewModelRouteCache-
The ViewModel route cache containing cached ViewModel-to-route mappings.
libraryConfigurationIOptions<LibraryConfiguration>-
The library configuration containing base path and other settings.
routeTemplateSelectorRouteTemplateSelector-
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 : IViewModelBaseReturns
- 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
keyobject-
The key used to determine the navigation URI.
Returns
- string
-
A relative URI path for navigation.
Exceptions
- ArgumentNullException
-
Thrown when
keyis 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 : IViewModelBaseParameters
forceLoadbool-
If
true, bypasses client-side routing and forces the browser to load the new page from the server. replacebool-
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 : IViewModelBaseParameters
optionsBrowserNavigationOptions-
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 : IViewModelBaseParameters
relativeUristring-
The relative URI or query string to append.
forceLoadbool-
If
true, bypasses client-side routing and forces the browser to load the new page from the server. replacebool-
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
relativeUriis 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 : IViewModelBaseParameters
relativeUristring-
The relative URI or query string to append.
optionsBrowserNavigationOptions-
Additional BrowserNavigationOptions for navigation.
Type Parameters
TViewModel-
The type implementing IViewModelBase to determine the navigation URI.
Exceptions
- ArgumentNullException
-
Thrown when
relativeUriis 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
keyobject-
The key used to determine the navigation URI.
forceLoadbool-
If
true, bypasses client-side routing and forces the browser to load the new page from the server. replacebool-
If
true, replaces the current entry in the history stack.
Exceptions
- ArgumentNullException
-
Thrown when
keyis 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
keyobject-
The key used to determine the navigation URI.
optionsBrowserNavigationOptions-
Additional BrowserNavigationOptions for navigation.
Exceptions
- ArgumentNullException
-
Thrown when
keyis 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
keyobject-
The key used to determine the navigation URI.
relativeUristring-
The relative URI or query string to append.
forceLoadbool-
If
true, bypasses client-side routing and forces the browser to load the new page from the server. replacebool-
If
true, replaces the current entry in the history stack.
Exceptions
- ArgumentNullException
-
Thrown when
keyorrelativeUriis 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
keyobject-
The key used to determine the navigation URI.
relativeUristring-
The relative URI or query string to append.
optionsBrowserNavigationOptions-
Additional BrowserNavigationOptions for navigation.
Exceptions
- ArgumentNullException
-
Thrown when
keyorrelativeUriis null.