7.2 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-16T03:28:26.668106+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 07b6bc1210aae7cd |
ViewModel
Documentation: PropertyViewModel Module
1. Purpose
The PropertyViewModel class serves as the view model for a property editing UI in the DTS (Data Tracking System) application, implementing Prism’s MVVM pattern and integrating with Unity dependency injection and region management. It acts as a bridge between the IPropertyView UI layer and underlying domain data (_properties), while also exposing Prism InteractionRequests for displaying notifications and confirmations. It inherits from BaseViewModel<IGraphPropertyViewModel>, suggesting it participates in a broader graph-based property editing context (e.g., for editing properties of nodes/edges in a graph model), though current implementation is largely skeletal.
2. Public Interface
PropertyViewModel(IPropertyView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer)
- Behavior: Constructor. Assigns the provided
view, setsview.DataContext = this, initializesNotificationRequestandConfirmationRequest, registersOnRaiseNotificationas a handler for theRaiseNotificationevent viaEventAggregator, and stores references to infrastructure services.
InteractionRequest<Notification> NotificationRequest { get; }
- Behavior: Prism interaction request used to raise notification popups (e.g., informational messages). Triggered internally via
OnRaiseNotificationwhen aRaiseNotificationevent is published.
InteractionRequest<Confirmation> ConfirmationRequest { get; }
- Behavior: Prism interaction request used to raise confirmation dialogs (e.g., yes/no prompts). Currently unused in the provided source.
IPropertyView View { get; }
- Behavior: Read-only reference to the associated view instance. Set during construction and never modified.
string HeaderInfo { get; }
- Behavior: Returns the static header string
"Graph Property".
object Properties { get; set; }
- Behavior: Holds arbitrary property data (likely a domain object or DTO representing editable properties). Raises
PropertyChangedwhen set.
override void Initialize(object parameter)
- Behavior: Assigns
Parentfrom the castparametertoIBaseWindowModel. Note: Does not callbase.Initialize(parameter).
void Initialize(object parameter, object properties)
- Behavior: Assigns
Parentand_propertiesfrom the respective parameters. Note: Does not raisePropertyChangedforPropertieshere — only the property setter does.
override event PropertyChangedEventHandler PropertyChanged
- Behavior: Overrides base
INotifyPropertyChangedimplementation. Note: Usesnewto hide base implementation.
override void Cleanup(), override Task CleanupAsync(), override void Activated(), override Task InitializeAsync(), override Task InitializeAsync(object parameter)
- Behavior: All currently throw
NotImplementedException. These lifecycle methods are declared but not implemented.
override void Initialize(), override Task InitializeAsync()
- Behavior: Empty overrides (no-op). No base call or logic.
3. Invariants
View.DataContextis always set tothis(PropertyViewModelinstance) immediately after construction.NotificationRequestandConfirmationRequestare initialized once and never reassigned.EventAggregator.GetEvent<RaiseNotification>().Subscribe(OnRaiseNotification)is called exactly once in the constructor — implying a single subscription for the lifetime of the instance (no unsubscription logic is present).Parentis assigned only viaInitialize(object parameter)orInitialize(object parameter, object properties)— not in the constructor.Propertiesproperty setter triggersOnPropertyChanged("Properties"), ensuring UI binding updates.
4. Dependencies
External Dependencies (via imports):
DTS.Common.Base→BaseViewModel<IGraphPropertyViewModel>DTS.Common.Events→RaiseNotification,NotificationContentEventArgsDTS.Common.Interface→IPropertyView,IBaseWindowModel,IGraphPropertyViewModelMicrosoft.Practices.Prism.Events→IEventAggregator,EventAggregatorMicrosoft.Practices.Prism.Interactivity.InteractionRequest→InteractionRequest<T>,Notification,ConfirmationMicrosoft.Practices.Prism.Regions→IRegionManagerMicrosoft.Practices.Unity→IUnityContainer
Internal Dependencies (inferred):
BaseViewModel<IGraphPropertyViewModel>— base class providing region/event/container infrastructure.RaiseNotificationevent (fromDTS.Common.Events) — expected to be published elsewhere in the system to trigger notifications via this VM.IBaseWindowModel— expected to be passed asparameterduring initialization (likely represents a parent window or graph context).IPropertyView— must be provided at construction; implies a corresponding view class implementing this interface.
Depended upon by:
- Likely consumed by Prism region navigation (e.g., via
IRegionManager.RequestNavigate) givenIRegionManagerusage. IUnityContainerusage suggests it is registered and resolved via Unity DI.
5. Gotchas
- Critical Unimplemented Methods:
Activated(),Cleanup(),CleanupAsync(),InitializeAsync(), andInitializeAsync(object)all throwNotImplementedException. This may cause runtime failures if Prism’s lifecycle expects these to be called (e.g., during region navigation or view disposal). - Missing
IsBusy/IsDirtyImplementation: PropertiesIsBusyandIsDirtythrowNotImplementedExceptionin both getter and setter — likely placeholders. - No Unsubscription from
RaiseNotificationEvent: The constructor subscribes toRaiseNotificationbut never unsubscribes. IfPropertyViewModelinstances are long-lived or reused, this could lead to memory leaks or duplicate notifications. Propertiessetter uses"Properties"string literal: Prone to refactoring errors (e.g., renaming field/property without updating string). Nonameof()usage.newkeyword usage:new event PropertyChangedEventHandler,new IRegionManager,new bool IsBusy,new bool IsDirty— suggests the base class (BaseViewModel<...>) declares members with the same names. This can cause confusion and subtle bugs if consumers expect base behavior.NotificationRequest.Raise(...)expectsNotificationContentEventArgsWithoutTitle: The comment states theNotificationobject expects aNotificationContentEventArgsWithoutTitle, but the code constructs aNotificationContentEventArgs. This mismatch may indicate a bug or undocumented type alias/conversion — unclear from source alone.- No validation or null checks:
parameteris cast directly toIBaseWindowModel— will throwInvalidCastExceptionif incorrect type is passed.
None identified from source alone. — Correction: The above gotchas are apparent from source analysis.