92 lines
5.6 KiB
Markdown
92 lines
5.6 KiB
Markdown
---
|
|
source_files:
|
|
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.Navigation/ViewModel/NavigationViewModel.cs
|
|
generated_at: "2026-04-16T11:19:33.784254+00:00"
|
|
model: "zai-org/GLM-5-FP8"
|
|
schema_version: 1
|
|
sha256: "17ac7f526470fc92"
|
|
---
|
|
|
|
# Documentation: NavigationViewModel
|
|
|
|
## 1. Purpose
|
|
|
|
`NavigationViewModel` is a ViewModel component responsible for managing the navigation UI region within the DTS Viewer application. It serves as a mediator between the `INavigationView` and the application's navigation system, handling notification and confirmation dialogs via Prism's interaction request patterns. The class inherits from `BaseViewModel<INavigationViewModel>` and implements `INavigationViewModel`, integrating with the Prism/Unity dependency injection and region management framework.
|
|
|
|
---
|
|
|
|
## 2. Public Interface
|
|
|
|
### Constructor
|
|
|
|
```csharp
|
|
public NavigationViewModel(INavigationView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer)
|
|
```
|
|
Initializes the navigation view model with its dependencies. Sets the view's `DataContext` to itself, creates `NotificationRequest` and `ConfirmationRequest` instances, and subscribes to the `RaiseNotification` event via the event aggregator.
|
|
|
|
### Properties
|
|
|
|
| Property | Signature | Description |
|
|
|----------|-----------|-------------|
|
|
| `NavigationView` | `INavigationView { get; private set; }` | Holds the associated navigation view instance. |
|
|
| `NotificationRequest` | `InteractionRequest<Notification> { get; private set; }` | Interaction request for displaying notifications. |
|
|
| `ConfirmationRequest` | `new InteractionRequest<Confirmation> { get; private set; }` | Interaction request for displaying confirmations. Hides base member. |
|
|
| `ContextNavigationRegion` | `object { get; set; }` | Gets or sets the content of the `NavigationRegion` on the concrete `NavigationView`. Raises `OnPropertyChanged` on set. |
|
|
| `HeaderInfo` | `string { get; }` | Returns the constant string `"NavigationRegion"`. |
|
|
| `IsBusy` | `new bool { get; set; }` | Throws `NotImplementedException` on both getter and setter. Hides base member. |
|
|
| `IsDirty` | `new bool { get; }` | Throws `NotImplementedException` on getter. Hides base member. |
|
|
| `IsNavigationIncluded` | `new bool { get; set; }` | Auto-property hiding base member. |
|
|
|
|
### Events
|
|
|
|
| Event | Signature | Description |
|
|
|-------|-----------|-------------|
|
|
| `PropertyChanged` | `new event PropertyChangedEventHandler` | Hides the base class event. Invoked via `OnPropertyChanged`. |
|
|
|
|
### Methods
|
|
|
|
| Method | Signature | Description |
|
|
|--------|-----------|-------------|
|
|
| `Initialize` | `override void Initialize()` | Empty override. No initialization logic. |
|
|
| `Initialize` | `override void Initialize(object parameter)` | Casts `parameter` to `IBaseViewModel` and assigns to private `Parent` field. |
|
|
| `OnRaiseNotification` | `void OnRaiseNotification(NotificationContentEventArgs eventArgsWithTitle)` | Private event handler. Converts `NotificationContentEventArgs` to `NotificationContentEventArgsWithoutTitle` and raises the `NotificationRequest`. |
|
|
|
|
---
|
|
|
|
## 3. Invariants
|
|
|
|
- `NavigationView` is assigned in the constructor and is expected to be non-null throughout the instance lifetime.
|
|
- The `DataContext` of `NavigationView` is always set to `this` (the ViewModel itself).
|
|
- `NotificationRequest` and `ConfirmationRequest` are initialized in the constructor and never reassigned.
|
|
- The `RaiseNotification` event subscription is established at construction time and remains active for the instance lifetime.
|
|
- `ContextNavigationRegion` property getter assumes `NavigationView` can be cast to the concrete `NavigationView` type and that `NavigationRegion` is non-null.
|
|
|
|
---
|
|
|
|
## 4. Dependencies
|
|
|
|
### This module depends on:
|
|
- `DTS.Common.Base` — `BaseViewModel<T>`, `IBaseViewModel`
|
|
- `DTS.Common.Events` — `RaiseNotification` (event), `NotificationContentEventArgs`
|
|
- `DTS.Common.Interactivity` — `InteractionRequest<T>`, `Notification`, `Confirmation`
|
|
- `DTS.Common.Interface` — `INavigationViewModel`, `INavigationView`
|
|
- `Prism.Events` — `IEventAggregator`
|
|
- `Prism.Regions` — `IRegionManager`
|
|
- `Unity` — `IUnityContainer`
|
|
|
|
### Consumers:
|
|
- Not determinable from this source file alone. The class is public and designed for use by other modules in the DTS.Viewer application.
|
|
|
|
---
|
|
|
|
## 5. Gotchas
|
|
|
|
1. **Member hiding with `new` keyword**: Multiple members (`ConfirmationRequest`, `IsBusy`, `IsDirty`, `IsNavigationIncluded`, `PropertyChanged`) use `new` to hide base class members. This can cause confusion when casting to base types or interfaces, as the hidden members will not be invoked.
|
|
|
|
2. **NotImplementedException on `IsBusy` and `IsDirty`**: Both properties throw `NotImplementedException` on access. Calling code must not attempt to read or write these properties.
|
|
|
|
3. **Concrete type cast in `ContextNavigationRegion`**: The property casts `INavigationView NavigationView` to the concrete `NavigationView` type to access `NavigationRegion.Content`. This breaks the abstraction provided by the interface and creates tight coupling to the concrete view implementation.
|
|
|
|
4. **Unused private fields**: `Parent`, `EventAggregator`, and `UnityContainer` are stored as private fields but `Parent` is only assigned (never read), and `EventAggregator`/`UnityContainer` are only used for subscription in the constructor. This may indicate incomplete implementation or dead code.
|
|
|
|
5. **ReSharper suppression directives**: The file contains multiple `// ReSharper disable` comments (`CheckNamespace`, `NotAccessedField.Local`, `UnusedAutoPropertyAccessor.Local`, `AutoPropertyCanBeMadeGetOnly.Local`), suggesting known code quality issues that have been suppressed rather than addressed. |