Files

105 lines
5.6 KiB
Markdown
Raw Permalink Normal View History

2026-04-17 14:55:32 -04:00
---
source_files:
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.Navigation/ViewModel/NavigationViewModel.cs
generated_at: "2026-04-16T13:57:29.392045+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "17ac7f526470fc92"
---
# Documentation: NavigationViewModel
## 1. Purpose
The `NavigationViewModel` class serves as the view model for the navigation component within the DTS Viewer application. It acts as a mediator between the `INavigationView` and the application's navigation infrastructure, managing the content displayed in the navigation region and handling notification events via Prism's `IEventAggregator`. This class inherits from `BaseViewModel<INavigationViewModel>` and implements `INavigationViewModel`, providing data binding context for the navigation view and supporting interaction requests for notifications and confirmations.
---
## 2. Public Interface
### Constructor
```csharp
public NavigationViewModel(INavigationView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer)
```
Initializes a new instance of `NavigationViewModel`. Sets the view's `DataContext` to itself, creates new `NotificationRequest` and `ConfirmationRequest` instances, stores references to the event aggregator and Unity container, and subscribes to the `RaiseNotification` event.
---
### Properties
| Property | Type | Description |
|----------|------|-------------|
| `NavigationView` | `INavigationView` | Gets the associated navigation view instance. Set once in constructor. |
| `NotificationRequest` | `InteractionRequest<Notification>` | Interaction request for displaying notifications to the user. |
| `ConfirmationRequest` | `InteractionRequest<Confirmation>` | Interaction request for displaying confirmation dialogs. Declared with `new` keyword. |
| `ContextNavigationRegion` | `object` | Gets or sets the content of the navigation region. Getter/setter directly access `((NavigationView)NavigationView).NavigationRegion.Content`. Raises `PropertyChanged` on set. |
| `HeaderInfo` | `string` | Returns the constant string `"NavigationRegion"`. |
| `IsBusy` | `bool` | Getter and setter both throw `NotImplementedException`. Declared with `new` keyword. |
| `IsDirty` | `bool` | Getter throws `NotImplementedException`. Declared with `new` keyword. |
| `IsNavigationIncluded` | `bool` | Get/set property. Declared with `new` keyword. |
---
### Methods
```csharp
public override void Initialize()
```
Overrides base `Initialize()`. Empty implementation.
```csharp
public override void Initialize(object parameter)
```
Overrides base `Initialize(object)`. Casts `parameter` to `IBaseViewModel` and assigns it to the private `Parent` property.
---
### Events
```csharp
public new event PropertyChangedEventHandler PropertyChanged
```
Event for property change notifications. Declared with `new` keyword, hiding the base class event.
---
## 3. Invariants
- `NavigationView` is assigned exactly once in the constructor and is never null thereafter (assumes constructor parameter is non-null).
- `NotificationRequest` and `ConfirmationRequest` are instantiated in the constructor and remain non-null for the lifetime of the view model.
- The `HeaderInfo` property always returns the literal string `"NavigationRegion"`.
- `IsBusy` and `IsDirty` properties will always throw `NotImplementedException` when accessed.
- The view model subscribes to `RaiseNotification` event during construction; the subscription persists for the object's lifetime.
---
## 4. Dependencies
### This Module Depends On:
- `DTS.Common.Base` — Provides `BaseViewModel<T>` and `IBaseViewModel`
- `DTS.Common.Events` — Provides `RaiseNotification` event and `NotificationContentEventArgs`
- `DTS.Common.Interactivity` — Provides `InteractionRequest<T>`, `Notification`, `Confirmation`
- `DTS.Common.Interface` — Provides `INavigationView`, `INavigationViewModel`
- `Prism.Events` — Provides `IEventAggregator`
- `Prism.Regions` — Provides `IRegionManager`
- `Unity` — Provides `IUnityContainer`
### What Depends On This Module:
- Cannot be determined from source alone. The `INavigationViewModel` interface suggests other modules may reference this view model through its interface abstraction.
---
## 5. Gotchas
1. **Multiple `new` keyword usages**: The properties `ConfirmationRequest`, `IsBusy`, `IsDirty`, `IsNavigationIncluded`, the `PropertyChanged` event, and the `OnPropertyChanged` method are all declared with `new`, hiding base class members. This indicates a design issue where the base class and derived class have conflicting member signatures. Callers casting to the base type will not see these overridden members.
2. **NotImplementedException on `IsBusy` and `IsDirty`**: Accessing either property will always throw. Code that attempts to bind to or check these properties will fail at runtime.
3. **Unused `ConfirmationRequest`**: The `ConfirmationRequest` property is instantiated but never raised anywhere in this class. It may be dead code or intended for future use.
4. **Concrete type cast in `ContextNavigationRegion`**: The property casts `INavigationView NavigationView` to the concrete type `NavigationView` to access `NavigationRegion.Content`. This breaks the interface abstraction and creates tight coupling to the concrete view implementation.
5. **`Parent` property never used**: The `Parent` property is set in `Initialize(object parameter)` but never referenced elsewhere in this file. Its purpose is unclear from source alone.
6. **Suppressed ReSharper warnings**: The file includes pragma-like comments suppressing warnings about unaccessed fields and unused auto-property accessors, suggesting known code quality issues that were silenced rather than resolved.