Files
2026-04-17 14:55:32 -04:00

116 lines
7.6 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
source_files:
- DataPRO/Modules/SystemSettings/Tables/ViewModel/TablesSettingsViewModel.cs
generated_at: "2026-04-16T04:40:21.830816+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "d6165d55cd0ea9cd"
---
# ViewModel
## Documentation: `TablesSettingsViewModel`
---
### 1. **Purpose**
`TablesSettingsViewModel` is the view model for the *Tables Settings* module within the applications UI layer. It acts as the data context for `ITablesSettingsView`, coordinating UI state (e.g., busy status, menu/navigation visibility) and bridging communication between the view and the applications event infrastructure via `IEventAggregator`. It also exposes `InteractionRequest`s to support modal notifications and confirmations through Prisms interaction patterns. This module is part of a modular, MEF-exported component system and is intended to be shared across the application lifecycle.
---
### 2. **Public Interface**
#### **Class: `TablesSettingsViewModel`**
- **Exported as:** `[Export(typeof(ITablesSettingsView))]` — implies it is intended to be resolved as an `ITablesSettingsView` (likely via MEF or Unity).
- **Creation Policy:** `Shared` — only one instance exists per application lifetime.
##### **Properties**
| Property | Type | Description |
|---------|------|-------------|
| `View` | `ITablesSettingsView` | Reference to the associated view; set in constructor. |
| `NotificationRequest` | `InteractionRequest<Notification>` | Used to trigger display of notification popups (e.g., informational messages). |
| `ConfirmationRequest` | `InteractionRequest<Confirmation>` | Used to trigger confirmation dialogs. |
| `IsDirty` | `bool` | Read-only; currently always `false` (no logic implemented to set it). |
| `IsBusy` | `bool` | Gets/sets busy state; raises `PropertyChanged` on change. |
| `IsMenuIncluded` | `bool` | Gets/sets whether the menu is included in the view; raises `PropertyChanged`. |
| `IsNavigationIncluded` | `bool` | Gets/sets whether navigation is included in the view; raises `PropertyChanged`. |
| `HeaderInfo` | `string` | Read-only; always returns `"MainRegion"`. |
##### **Methods**
| Method | Signature | Description |
|--------|-----------|-------------|
| `Cleanup` | `void Cleanup()` | No-op stub. |
| `CleanupAsync` | `Task CleanupAsync()` | Returns `Task.CompletedTask`. |
| `Initialize` | `void Initialize()` | No-op stub. |
| `Initialize` | `void Initialize(object parameter)` | No-op stub. |
| `Initialize` | `void Initialize(object parameter, object model)` | No-op stub. |
| `InitializeAsync` | `Task InitializeAsync()` | Returns `Task.CompletedTask`. |
| `InitializeAsync` | `Task InitializeAsync(object parameter)` | Returns `Task.CompletedTask`. |
| `Activated` | `void Activated()` | No-op stub. |
##### **Event Handlers (Private)**
| Method | Signature | Description |
|--------|-----------|-------------|
| `OnBusyIndicatorNotification` | `private void OnBusyIndicatorNotification(bool eventArg)` | Sets `IsBusy` to `eventArg`. |
| `OnRaiseNotification` | `private void OnRaiseNotification(NotificationContentEventArgs eventArgsWithTitle)` | Transforms `NotificationContentEventArgs` (with title/message/image) into a `Notification` object and raises `NotificationRequest`. Note: it discards the `Title` and `Image` fields of the original event args and passes them via `NotificationContentEventArgs` constructor with empty strings for some parameters — see *Gotchas*. |
##### **Interface Implementations**
| Interface | Method | Signature | Description |
|-----------|--------|-----------|-------------|
| `INotifyPropertyChanged` | `PropertyChanged` | `event PropertyChangedEventHandler PropertyChanged` | Raised via `OnPropertyChanged`. |
| `IBasePropertyChanged` | `OnPropertyChanged` | `void IBasePropertyChanged.OnPropertyChanged(string propertyName)` | Delegates to `OnPropertyChanged(propertyName)`. |
| — | `SetProperty` | `bool SetProperty<T>(ref T storage, T value, string propertyName = null)` | **Throws `NotImplementedException`** — not implemented. |
---
### 3. **Invariants**
- `View.DataContext` is always set to `this` (the view model) in the constructor.
- `IsBusy` is initialized to `false` and only modified via `OnBusyIndicatorNotification`, which is subscribed to `BusyIndicatorChangeNotification`.
- `NotificationRequest` and `ConfirmationRequest` are initialized in the constructor and never reassigned.
- `HeaderInfo` is a constant string `"MainRegion"` and never changes.
- `IsDirty` is declared but never set — its value remains `false` for the lifetime of the instance.
- `SetProperty` is declared but unimplemented — calling it will always throw `NotImplementedException`.
---
### 4. **Dependencies**
#### **Imports / Dependencies (via constructor parameters and `using` directives)**
- **Prism Libraries**:
- `IEventAggregator` — for pub/sub event handling.
- `IRegionManager` — for region navigation (though unused in current implementation).
- `Unity` container (`IUnityContainer`) — for dependency injection.
- **Custom Infrastructure**:
- `DTS.Common.Events.RaiseNotification` — event type subscribed to in constructor.
- `DTS.Common.Events.BusyIndicatorChangeNotification` — event type subscribed to in constructor.
- `DTS.Common.Base.IBasePropertyChanged` — interface implemented explicitly.
- `DTS.Common.Interface.ITablesSettingsView` — view interface.
- **MEF**:
- `[Export(typeof(ITablesSettingsView))]` — indicates this type is registered as an export for `ITablesSettingsView`.
- **UI Framework**:
- `Prism.Regions`, `Prism.Events`, `Prism.Interactivity` — used for region management, event aggregation, and interaction requests.
#### **Depended Upon By**
- The view (`ITablesSettingsView`) — this view model is bound to its `DataContext`.
- Likely consumed via MEF/Unity resolution as `ITablesSettingsView`.
- Other modules may publish `RaiseNotification` or `BusyIndicatorChangeNotification` events to trigger UI feedback via this view model.
---
### 5. **Gotchas**
- **`SetProperty` is unimplemented** — throws `NotImplementedException`. This breaks expected MVVM patterns (e.g., `INotifyPropertyChanged` helpers). Developers should avoid calling it.
- **`NotificationContentEventArgs` transformation in `OnRaiseNotification` is lossy**:
The method constructs a new `NotificationContentEventArgs` with empty strings for the 2nd and 4th parameters (likely `OkContent` and `CancelContent`), discarding any original values. This may cause unexpected behavior if callers expect those fields to be preserved.
- **No-op lifecycle methods**: `Initialize`, `InitializeAsync`, `Activated`, `Cleanup`, and `CleanupAsync` contain no logic — may indicate incomplete implementation or deferred functionality.
- **`IsDirty` is never set**: Despite being a public property, it is never assigned — always `false`. This may mislead consumers expecting dirty-state tracking.
- **`HeaderInfo` is hardcoded**: Always returns `"MainRegion"` — no dynamic behavior or configuration.
- **`IBasePropertyChanged.OnPropertyChanged` is implemented explicitly** — only callable via interface cast.
- **Thread context for `BusyIndicatorChangeNotification`**: Subscribed with `ThreadOption.PublisherThread`, meaning the handler runs on the publishers thread — may require dispatcher marshaling if the publisher is not on the UI thread (though `IsBusy` setter calls `OnPropertyChanged`, which *should* marshal to UI thread if `INotifyPropertyChanged` is handled by Prisms binding system).
---
*Documentation generated from source file `TablesSettingsViewModel.cs` only. No external behavior or assumptions beyond what is visible in the source.*