--- source_files: - DataPRO/Modules/TestSetups/CachedItemsList/ViewModel/CachedItemsListViewModel.cs generated_at: "2026-04-17T16:00:55.338770+00:00" model: "zai-org/GLM-5-FP8" schema_version: 1 sha256: "fbd3e29061155d1a" --- # CachedItemsListViewModel Documentation ## 1. Purpose `CachedItemsListViewModel` is a Prism/MEF view model for the Cached Items List module within the DTS (Data Test System) test setup framework. It serves as the presentation logic layer for displaying and managing cached items—specifically sensors, hardware components, and sensor calibrations—comparing in-memory cached data against database records to identify discrepancies. The class implements the `INotifyPropertyChanged` pattern and integrates with the application's event aggregation and region management infrastructure. ## 2. Public Interface ### Constructor ```csharp public CachedItemsListViewModel(ICachedItemsListView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer) ``` Initializes the view model, sets the view's DataContext, creates interaction requests, and subscribes to `RaiseNotification` and `BusyIndicatorChangeNotification` events. ### Properties | Property | Type | Description | |----------|------|-------------| | `View` | `ICachedItemsListView` | The associated view instance. | | `NotificationRequest` | `InteractionRequest` | Used to raise notification dialogs. | | `ConfirmationRequest` | `InteractionRequest` | Used to raise confirmation dialogs. | | `CachedItems` | `ICachedItem[]` | Array of cached items. Initialized to empty array. | | `IsDirty` | `bool` | Always returns `false`. | | `IsBusy` | `bool` | Busy indicator state, triggers `PropertyChanged`. | | `IsMenuIncluded` | `bool` | Menu inclusion flag, triggers `PropertyChanged`. | | `IsNavigationIncluded` | `bool` | Navigation inclusion flag, triggers `PropertyChanged`. | | `HasOutofDateCachedItems` | `bool` | Returns `true` if `CachedItems` contains any elements. | | `HasMissingSensors` | `bool` | Returns `true` if any cached item has `DBTime == DateTime.MinValue` and `ObjectType == Resources.StringResources.Sensor`. | ### Events ```csharp public event PropertyChangedEventHandler PropertyChanged ``` Standard `INotifyPropertyChanged` event. ### Methods ```csharp public void OnPropertyChanged(string propertyName) ``` Invokes the `PropertyChanged` event if handlers are attached. ```csharp public void Unset() public void Cleanup() public Task CleanupAsync() public void Initialize() public void Initialize(object parameter) public void Initialize(object parameter, object model) public Task InitializeAsync() public Task InitializeAsync(object parameter) public void Activated() ``` Lifecycle methods—currently all empty implementations. `CleanupAsync`, `InitializeAsync`, and `InitializeAsync(object parameter)` return `Task.CompletedTask`. ```csharp public bool SetCachedItems(ISensorData[] sensors, ISensorCalibration[] sensorCalibrations, IDASHardware[] hardware, IDASHardware[] allDAS) ``` Intended to populate `CachedItems` by comparing provided sensors, calibrations, and hardware against database records. **Currently returns `false` immediately; all logic is commented out.** ## 3. Invariants - **Singleton lifetime**: The class is decorated with `[PartCreationPolicy(CreationPolicy.Shared)]`, ensuring a single shared instance via MEF. - **`IsDirty` is always `false`**: The property has no backing logic to track actual dirty state. - **`CachedItems` is never null**: Property is initialized to an empty array `new ICachedItem[0]`. - **Event subscriptions are keep-subscribed**: `BusyIndicatorChangeNotification` is subscribed with `keepSubscriberReferenceAlive: true`, preventing weak reference cleanup. - **`HasOutofDateCachedItems` naming**: Despite the name, it simply checks if any items