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

12 KiB

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.TestSummaryList/ViewModel/TestSummaryViewModel.cs
DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.TestSummaryList/ViewModel/TestSummaryViewListModel.cs
2026-04-16T13:54:46.702068+00:00 zai-org/GLM-5-FP8 1 b27cef2360f72751

Documentation: TestSummaryList ViewModels

1. Purpose

This module provides two ViewModel implementations (TestSummaryViewModel and TestSummaryViewListModel) for managing and displaying test summary data within the DTS Viewer application. Both classes implement ITestSummaryListViewModel and serve as intermediaries between test summary data models and their associated views, handling user interactions, event-based communication via Prism's EventAggregator, and data binding for test summary lists. The module supports filtering, sorting, selection tracking, and notification of changes to other application components.


2. Public Interface

TestSummaryViewModel

Constructor:

public TestSummaryViewModel(ITestSummaryListView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer)

Initializes the ViewModel, sets the View's DataContext, creates interaction requests, and subscribes to RaiseNotification and DataFolderChangedEvent events.

Methods:

Method Signature Description
Initialize void Initialize() Empty override.
Initialize void Initialize(object parameter) Casts parameter to IBaseWindowModel and assigns to Parent.
Activated void Activated() Throws NotImplementedException.
Cleanup void Cleanup() Throws NotImplementedException.
CleanupAsync Task CleanupAsync() Throws NotImplementedException.
InitializeAsync Task InitializeAsync() Throws NotImplementedException.
InitializeAsync Task InitializeAsync(object parameter) Throws NotImplementedException.
PublishSelectedTestSummaryList void PublishSelectedTestSummaryList() Publishes TestSummaryChangeNotification and TestSelectedChangedEvent events with current selection.

Properties:

Property Type Description
TestSummaryListView ITestSummaryListView The associated view instance.
NotificationRequest InteractionRequest<Notification> Prism interaction request for notifications.
ConfirmationRequest InteractionRequest<Confirmation> Prism interaction request for confirmations.
ContextNavigationRegion object Gets/sets content of TestListRegion on the view.
SelectedTestSummary TestSummary Currently selected test summary.
SelectedTestSummaryList List<ITestSummary> List of selected test summaries.
TestSummaryList ObservableCollection<ITestSummary> Collection of all test summaries.
HeaderInfo string Returns "TestSummaryRegion".
IsBusy bool Busy indicator state.
IsDirty bool Dirty state flag.
IsNavigationIncluded bool Navigation inclusion flag.

TestSummaryViewListModel

Constructor:

public TestSummaryViewListModel(ITestSummaryListView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer)

Initializes the ViewModel, sets the View's DataContext, creates interaction requests, and stores dependencies.

Methods:

Method Signature Description
Initialize void Initialize() Empty override.
Initialize void Initialize(object parameter) Sets Parent, initializes FilterView, attaches collection changed handlers, calls Subscribe().
Activated void Activated() Publishes FilterParameterChangedEvent with empty parameter.
Cleanup void Cleanup() Clears all test summary collections, resets SelectedTestSummary, calls PublishSelectedTestSummaryList().
PublishSelectedTestSummaryList void PublishSelectedTestSummaryList() Publishes TestSummaryChangeNotification, TestSummaryCountNotification, and ResetZoomChangedEvent events.
OnFilterChanged void OnFilterChanged(FilterParameterArgs args) Filters FilteredTestSummaryList based on args.Param matching SetupName, Id, or Description.
RefreshDataFolder void RefreshDataFolder() Publishes DataFolderChangedEvent via dispatcher.
SelectDataFolder void SelectDataFolder() Opens file dialog for .dts files, publishes DataFileSelectedEvent on selection.

Properties:

Property Type Description
FilterView IFilterView Filter view instance.
View ITestSummaryListView The associated view instance.
NotificationRequest InteractionRequest<Notification> Prism interaction request for notifications.
ConfirmationRequest InteractionRequest<Confirmation> Prism interaction request for confirmations.
ContextNavigationRegion object Gets/sets DataContext of TestListRegion on the view.
IsFilterEnabled bool Indicates if filtering is available (true when TestSummaryList has items).
SelectedTestSummary TestSummary Currently selected test summary.
SelectedTestSummaryList List<ITestSummary> List of selected test summaries.
TestSummaryList ObservableCollection<ITestSummary> Full collection of test summaries.
FilteredTestSummaryList ObservableCollection<ITestSummary> Filtered/sorted view of test summaries.
HeaderInfo string Returns "TestSummaryRegion".
IsBusy bool Busy indicator state.
IsDirty bool Dirty state flag.
IsNavigationIncluded bool Navigation inclusion flag.
SelectedDataFolder string Selected data folder path; setter publishes DataFolderChangedEvent.
SelectedDataFile string Selected data file path; setter publishes DataFolderChangedEvent.
SortableAttributes List<string> List of localized sortable attribute names.
SelectedSortIndex int Index of selected sort option; setter triggers SortTestSummaryList().

Commands:

Command Type Description
RefreshDataFolderCommand DelegateCommand Executes RefreshDataFolder().
SelectDataFolderCommand DelegateCommand Executes SelectDataFolder().

Nested Types:

Type Description
SortableAttribute (enum) Sort options: TimeStampDescending, Timestamp, FileDateDescending, FileDate, IdDescending, Id, TestSetupDescending, TestSetup.
SortableAttributeHelper Helper class for localizing sort attribute display names via StringResources.

3. Invariants

  • Parent Assignment: Initialize(object parameter) in both classes expects parameter to be castable to IBaseWindowModel (TestSummaryViewModel) or IBaseViewModel (TestSummaryViewListModel); a null or incorrect type will cause an invalid cast exception.
  • Event Subscription Timing: Event subscriptions occur in the constructor (TestSummaryViewModel) or in Initialize via Subscribe() (TestSummaryViewListModel); events published before initialization may not be received.
  • Collection Synchronization: In TestSummaryViewListModel, FilteredTestSummaryList is automatically synchronized with TestSummaryList via TestSummaryList_CollectionChanged handler.
  • Filter Ownership: OnFilterChanged only applies filtering when FilterView.DataContext.Parent equals this.
  • Data Folder Event Handling: OnDataFolderChanged in TestSummaryViewListModel only processes events where arg.ParentVM matches Parent.
  • Property Setters with Side Effects: SelectedDataFolder and SelectedDataFile setters publish events; setting to null or empty string returns early without publishing.
  • Sort Index Default: SelectedSortIndex defaults to (int)SortableAttribute.TimeStampDescending (value 0).

4. Dependencies

External Dependencies (from imports):

Namespace Purpose
DTS.Common.Base BaseViewModel<T> base class.
DTS.Common.Classes.TestMetadata / DTS.Common.Classes.Viewer.TestMetadata TestSummary, ITestSummary interfaces.
DTS.Common.Events Event types: RaiseNotification, DataFolderChangedEvent, ShowStatus, TestSummaryChangeNotification, TestSelectedChangedEvent, FilterParameterChangedEvent, RefreshTestRequestEvent, BusyIndicatorChangeNotification, TestSummaryCountNotification, ResetZoomChangedEvent, DataFileSelectedEvent.
DTS.Common.Interface IBaseWindowModel, IBaseViewModel, IEventAggregator usage patterns.
DTS.Common.Interface.TestDefinition ITestSummaryListViewModel, ITestSummaryListView.
DTS.Common.Interactivity NotificationContentEventArgs.
DTS.Viewer.TestSummaryList.Model TestSummaryModel for data loading.
DTS.Viewer.TestSummaryList.Resources StringResources for localization.
Microsoft.Practices.Prism.Events / Prism.Events EventAggregator pattern.
Microsoft.Practices.Prism.Interactivity.InteractionRequest / Prism.Interactivity InteractionRequest<T>, Notification, Confirmation.
Microsoft.Practices.Prism.Regions / Prism.Regions IRegionManager, region-based navigation.
Microsoft.Practices.Unity / Unity IUnityContainer for dependency injection.
Prism.Commands DelegateCommand.
System.Windows.Forms OpenFileDialog for file selection.

Internal Dependencies:

  • TestSummaryModel: Both ViewModels instantiate TestSummaryModel to call GetTestSummary() for loading data.
  • IFilterView / IFilterViewModel: TestSummaryViewListModel resolves these via Unity container.

Consumers (inferred):

  • Views: TestSummaryView (referenced in TestSummaryViewModel.ContextNavigationRegion), TestSummaryListView (referenced in TestSummaryViewListModel.ContextNavigationRegion).
  • Any module subscribing to TestSummaryChangeNotification, TestSummaryCountNotification, TestSelectedChangedEvent, or ResetZoomChangedEvent.

5. Gotchas

Critical Issues:

  1. NotImplementedException Methods in TestSummaryViewModel: The following methods throw NotImplementedException: Activated(), Cleanup(), CleanupAsync(), InitializeAsync(), and InitializeAsync(object parameter). Calling these will crash the application.

  2. Misleading XML Documentation: The constructor XML comment in TestSummaryViewModel states "Creates a new instance of the TechnologyDoFrontEditViewModel" — this appears to be a copy-paste error from another class.

  3. Event Signature Mismatch: TestSummaryViewModel.OnDataFolderChanged(string path) expects a string parameter, while TestSummaryViewListModel.OnDataFolderChanged(DataFolderSelectionArg arg) expects DataFolderSelectionArg. The event DataFolderChangedEvent is subscribed by both with incompatible signatures — unclear which signature the event actually uses.

  4. new Keyword Shadowing: Both classes use new keyword on PropertyChanged, OnPropertyChanged, IsBusy, IsDirty, and IsNavigationIncluded. This suggests the base class BaseViewModel<T> already defines these members, and the shadowing may cause unexpected behavior when casting to base type.

  5. Direct View Casting: ContextNavigationRegion property directly casts the view interface to concrete types (TestSummaryView or TestSummaryListView), breaking the interface abstraction pattern.

  6. Dispatcher Usage in RefreshDataFolder: RefreshDataFolder() uses Dispatcher.CurrentDispatcher.Invoke() with DispatcherPriority.Background, which may cause timing issues if called from a non-UI thread.

  7. Sort Implementation Rebuilds Collection: SortTestSummaryList() clears and rebuilds FilteredTestSummaryList on every sort change, which may cause UI flicker and performance issues with large datasets.

  8. Missing Unsubscribe: Neither class unsubscribes from events in cleanup, potentially causing memory leaks if instances are not properly garbage collected.