7.1 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-16T04:41:41.270479+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 26d85367d0fdc737 |
ViewModel
Documentation: QASettingsViewModel
1. Purpose
The QASettingsViewModel serves as the view model for the QA Settings module in the application, implementing the IQASettingsViewModel interface and adhering to Prism’s MVVM pattern. It acts as the intermediary between the IQASettingsView UI and underlying system services (e.g., event aggregation, region management, dependency injection), enabling UI-driven interactions such as displaying notifications, managing busy state, and exposing configuration-related properties (e.g., counts of sensors, test setups). It also subscribes to global events (RaiseNotification, BusyIndicatorChangeNotification) to synchronize UI state with application-wide events.
2. Public Interface
QASettingsViewModel (class)
-
IQASettingsView View { get; }
Reference to the associated view instance; set during construction and used to bindDataContext. -
InteractionRequest<Notification> NotificationRequest { get; }
Prism interaction request used to trigger notification popups (e.g., informational messages). Raised viaOnRaiseNotification. -
InteractionRequest<Confirmation> ConfirmationRequest { get; }
Prism interaction request used to trigger confirmation dialogs (currently declared but not used in the provided source). -
bool IsBusy { get; set; }
Indicates whether the view/model is currently performing a long-running operation. Bound to a busy indicator in the UI. -
bool IsDirty { get; }
Property indicating whether changes have been made (currently alwaysfalse; no logic implemented to set it). -
bool IsMenuIncluded { get; set; }
Controls visibility of the menu in the view (defaultfalse). -
bool IsNavigationIncluded { get; set; }
Controls visibility of navigation controls in the view (defaultfalse). -
string HeaderInfo { get; }
Returns the literal string"MainRegion"; likely used as a header or region identifier. -
string NumberOfSensorModelsText { get; set; }
String representation of_numberOfSensorModels(formatted with thousand separators); setter parses input toint. -
string NumberOfTestSetupsText { get; set; }
String representation of_numberOfTestSetups. -
string NumberOfGroupsText { get; set; }
String representation of_numberOfGroups. -
string NumberOfSensorsText { get; set; }
String representation of_numberOfSensors. -
string NumberOfGroupTemplatesText { get; set; }
String representation of_numberOfGroupTemplates. -
DelegateCommand CreateCommand { get; }
Command bound to a UI action (e.g., a button). InvokesCreateMethod()asynchronously (note:async void—see Gotchas).
Interface Implementations
-
void Cleanup()/Task CleanupAsync()
No-op stubs; no cleanup logic implemented. -
void Initialize()/void Initialize(object parameter)/void Initialize(object parameter, object model)/Task InitializeAsync()/Task InitializeAsync(object parameter)
No-op stubs; no initialization logic implemented. -
void Activated()
No-op stub; likely part of Prism’sINavigationAwareor custom lifecycle interface. -
event PropertyChangedEventHandler PropertyChanged
StandardINotifyPropertyChangedimplementation; used for data binding. -
void OnPropertyChanged(string propertyName)
RaisesPropertyChangedevent for the given property. -
bool SetProperty<T>(ref T storage, T value, string propertyName = null)
Declared but throwsNotImplementedException; not used. -
void IBasePropertyChanged.OnPropertyChanged(string propertyName)
Explicit interface implementation ofIBasePropertyChanged.OnPropertyChanged, delegating toOnPropertyChanged.
3. Invariants
View.DataContextis always set tothis(the view model instance) during construction._eventAggregatorsubscriptions are established in the constructor and persist for the lifetime of the instance.IsBusyis updated synchronously in response toBusyIndicatorChangeNotificationevents.NumberOf*Textproperties parse their setters asintwithout validation—invalid input will throwFormatException.IsDirtyis read-only and never set totruein the current implementation.NotificationRequestis raised with aNotificationobject containing aNotificationContentEventArgs(with empty strings for unused fields) and the original title.- The class is marked
[PartCreationPolicy(CreationPolicy.Shared)], implying a singleton lifetime within the MEF container.
4. Dependencies
Imports / Dependencies
- Prism Framework:
Prism.Events.IEventAggregator(for event pub/sub)Prism.Regions.IRegionManager(for region navigation)Prism.Commands.DelegateCommand(for command binding)Prism.Interactivity.InteractionRequest(for popup notifications)
- Unity Container:
IUnityContainer(dependency injection) - Custom Interfaces/Events:
IQASettingsView(view interface)DTS.Common.Events.RaiseNotification,DTS.Common.Events.BusyIndicatorChangeNotification(event types)DTS.Common.Base.IBasePropertyChanged(custom interface)
- System Components:
System.ComponentModel.INotifyPropertyChanged,System.Threading.Tasks.Task
Exports / Used By
- Exported as
IQASettingsViewvia[Export(typeof(IQASettingsView))], implying it is consumed by a Prism region or view locator expecting that interface. - Likely consumed by the
QASettingsViewUI (e.g., XAML view bound to this VM).
5. Gotchas
-
async voidinCreateMethod():
TheCreateMethod()handler isasync void, which is generally discouraged (no way to await or handle exceptions properly). This may lead to unobserved exceptions. -
SetPropertythrowsNotImplementedException:
TheSetPropertymethod (commonly used in MVVM to reduce boilerplate for property setters) is declared but unimplemented. This suggests incomplete refactoring or copy-paste from a base class. -
No validation in property setters:
AllNumberOf*Textsetters useint.Parse(value)without error handling. Invalid input (e.g., non-numeric strings) will crash the UI thread. -
Unused
ConfirmationRequest:
Declared but never raised—likely leftover from design or future use. -
IsDirtyis alwaysfalse:
No logic tracks changes; this property is effectively dead code. -
HeaderInfois hardcoded:
Returns"MainRegion"literally—likely a placeholder or misnamed constant. -
IBasePropertyChangedinterface:
Custom interface (notINotifyPropertyChanged) is implemented explicitly, but its purpose is unclear from this file alone. -
No disposal logic:
_eventAggregatorsubscriptions are not unsubscribed inCleanup()/CleanupAsync()—risk of memory leaks if the view model outlives its view.