Files
DP44/docs/ai/DataPRO/Modules/TestSetups/CachedItemsList/ViewModel.md
2026-04-17 14:55:32 -04:00

3.8 KiB

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DataPRO/Modules/TestSetups/CachedItemsList/ViewModel/CachedItemsListViewModel.cs
2026-04-17T16:00:55.338770+00:00 zai-org/GLM-5-FP8 1 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

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<Notification> Used to raise notification dialogs.
ConfirmationRequest InteractionRequest<Confirmation> 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

public event PropertyChangedEventHandler PropertyChanged

Standard INotifyPropertyChanged event.

Methods

public void OnPropertyChanged(string propertyName)

Invokes the PropertyChanged event if handlers are attached.

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.

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