9.0 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-16T04:38:41.881863+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | d7dc80e73ad032ff |
ViewModel
ExtraPropertiesListViewModel Documentation
1. Purpose
ExtraPropertiesListViewModel is a Prism-based ViewModel responsible for managing a list of key-value extra properties associated with a data page in the ISO module of the DataPRO application. It provides UI-agnostic data binding, sorting, filtering, clipboard operations (copy/paste), validation, and event-driven integration with the broader application via IEventAggregator. It serves as the intermediary between the IExtraPropertiesListView UI and the underlying ExtraPropertyModel data entities, enabling users to edit, sort, filter, and validate property lists (e.g., metadata, tags, or custom attributes) in a tabular UI.
2. Public Interface
All members are defined in ExtraPropertiesListViewModel, which implements IExtraPropertiesListViewModel (inferred from interface usage). Only explicitly declared public or interface-implementing members are documented.
Properties
| Property | Type | Description |
|---|---|---|
View |
IExtraPropertiesListView |
Reference to the associated view; set externally. |
NotificationRequest |
InteractionRequest<Notification> |
Prism MVVM Toolkit interaction request for showing non-blocking notifications. |
ConfirmationRequest |
InteractionRequest<Confirmation> |
Prism MVVM Toolkit interaction request for showing confirmation dialogs. |
IsBusy |
bool |
Gets/sets busy state; raises PropertyChanged for "IsBusy". |
IsMenuIncluded |
bool |
Gets/sets whether a context menu is included in the view; raises PropertyChanged for "IsMenuIncluded". |
IsNavigationIncluded |
bool |
Gets/sets whether navigation controls are included; raises PropertyChanged for "IsNavigationIncluded". |
IsReadOnly |
bool |
Gets/sets read-only mode (prevents editing); raises PropertyChanged for "IsReadOnly". |
AllExtraProperties |
List<IExtraProperty> |
Full list of all extra properties (including empty trailing row). |
ExtraProperties |
ObservableCollection<IExtraProperty> |
Filtered/sorted view of AllExtraProperties, bound to UI. |
SelectedProperties |
IExtraProperty[] |
Throws NotImplementedException — not implemented. |
Page |
IDataPROPage |
The page this ViewModel is associated with (set via SetPage). |
Parent |
object |
Parent object (set via SetParent). |
IsDirty |
bool |
Declared but never set; always false. |
Events
| Event | Type | Description |
|---|---|---|
PropertyChanged |
PropertyChangedEventHandler |
Standard INotifyPropertyChanged event; raised via OnPropertyChanged. |
Methods
| Method | Signature | Description |
|---|---|---|
OnPropertyChanged |
void OnPropertyChanged(string propertyName) |
Raises PropertyChanged; if propertyName == "ExtraProperties", publishes ExtraPropertiesChangedEvent. |
SetPage |
void SetPage(IDataPROPage page) |
Sets Page. |
SetParent |
void SetParent(object parent) |
Sets Parent. |
Cleanup |
void Cleanup() |
No-op. |
CleanupAsync |
Task CleanupAsync() |
Returns Task.CompletedTask. |
Initialize / InitializeAsync |
Multiple overloads (e.g., void Initialize(), Task InitializeAsync(object parameter)) |
All are no-ops. |
Activated |
void Activated() |
No-op. |
Filter |
void Filter(object tag, string term) |
Sets search term for "Key" or "Value" (via tag string) and triggers Filter(). Bug: "Value" case incorrectly sets _searchTermForField[Fields.Key]. |
Sort |
void Sort(object columnTag, bool columnClick) |
Sets sort field ("Key" or "Value") and triggers Sort(...) + Filter(). |
Validate(ref List<string> errors) |
bool Validate(ref List<string> errors) |
Calls internal Validate(ref errors, ref warnings), returns true if no new errors added. |
SetExtraProperties |
void SetExtraProperties(IList<IExtraProperty> properties) |
Replaces AllExtraProperties with copies of input properties, appends a new empty ExtraPropertyModel, resets sort/filter, and re-applies. |
CopySelected |
void CopySelected() |
Copies selected items (_selectedItems) into AllExtraProperties (just before the trailing empty row), sorts, filters, and publishes PageModifiedEvent. |
DeleteSelected |
void DeleteSelected() |
Removes selected items from both ExtraProperties and AllExtraProperties; ensures trailing empty row is preserved; publishes PageModifiedEvent. |
Note
:
SelectedPropertiesis declared but throwsNotImplementedException. Its usage is likely incomplete or deprecated.
3. Invariants
- Trailing Empty Row:
AllExtraPropertiesalways ends with a single emptyExtraPropertyModelinstance (key/value both empty/whitespace). This is enforced in:SetExtraProperties(adds one after copying input),MarkModified(adds one if last item modified),DeleteSelected(re-adds one if deleted).
- Filtering Logic: Empty rows (both key and value whitespace) are always included in
ExtraPropertiesregardless of search term. - Sorting Behavior: Empty rows are always sorted to the bottom of
AllExtraProperties(viaPropertyComparer.Compare). - Validation Rules:
- Duplicate non-empty keys → error.
- Non-empty keys with empty/whitespace values → warning.
- Event Subscription Hack:
_bAddListenersstatic flag ensures only the second instantiation of this ViewModel subscribes toTextPastedEvent. First instantiation (likely during app startup) skips subscription.
4. Dependencies
Imports / Dependencies Used
- Prism Framework:
Prism.Events.IEventAggregator,Prism.Regions.IRegionManagerPrism.Interactivity.InteractionRequest(Notification,Confirmation)
- Unity DI Container:
IUnityContainer - DataPRO Common Libraries:
DTS.Common.Events.*(e.g.,TextPastedEvent,PageModifiedEvent,PageSelectionChanged)DTS.Common.Interface.*(IDataPROPage,IExtraProperty,IExtraPropertiesListView,IExtraPropertiesListViewModel)DTS.Common.Utilities.NaturalStringComparer(used inPropertyComparer)
- Model Layer:
ExtraProperties.Model.ExtraPropertyModel(concrete implementation ofIExtraProperty)
- Resources:
ExtraProperties.Resources.StringResources(for error/warning messages)
Consumers (Inferred)
ExtraPropertiesListViewModelis instantiated via Unity DI (due to[PartCreationPolicy(CreationPolicy.Shared)]and constructor injection).- Likely consumed by
IExtraPropertiesListView(WPF view) bound to this ViewModel. - Subscribes to events published by other modules (e.g.,
TextPastedEventfrom clipboard operations). - Publishes
PageModifiedEvent,ExtraPropertiesChangedEvent, andPageSelectionChanged.
5. Gotchas
SelectedPropertiesis unimplemented: ThrowsNotImplementedException. Any code expecting this property will crash.Filterbug: When filtering by"Value", it incorrectly assigns the term to_searchTermForField[Fields.Key]instead ofFields.Value._bAddListenershack: Static boolean_bAddListenerscontrolsTextPastedEventsubscription. First instantiation does not subscribe; only the second (and subsequent) do. This is fragile and may break if instantiation order changes.IsDirtynever set: Property is declared but never assigned; alwaysfalse.Sort/Filterorder:Sortis called beforeFilterinFilter(object, string)andSort(object, bool), butFilter()is called afterSort(...)inPaste,CopySelected, andDeleteSelected. This is consistent but non-obvious.- Paste behavior:
PastemodifiesExtraPropertiesin-place (by index), butAllExtraPropertiesis not updated untilSort/Filterare called. This may cause inconsistency if accessed mid-operation. - Case sensitivity: Sorting and filtering use
ToUpper()+NaturalStringComparer, which may not match user expectations for case-insensitive comparisons (e.g.,"a"and"A"sort as equal, but"ä"vs"a"may behave unexpectedly). - No null checks in
PropertyComparer: Whileleft == rightis handled,a/bcould benullafter assignment (e.g., ifleft/rightare non-null but one becomesnullafterSortAscendingswap logic).nullchecks exist but may not cover all paths. MarkModifiedside effect: Appends a new empty row only if the modified item is the last inExtraProperties, but usesExtraProperties.Last()— which is the filtered list — notAllExtraProperties. This may cause inconsistent behavior if filtering is active.
Documentation generated from ExtraPropertiesListViewModel.cs (DataPRO/Modules/ISO/ExtraProperties/ViewModel/ExtraPropertiesListViewModel.cs).