16 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||||
|---|---|---|---|---|---|---|---|---|---|
|
2026-04-16T11:23:08.528119+00:00 | zai-org/GLM-5-FP8 | 1 | 7a17d7bd36c83744 |
DTS.Viewer ViewModel Documentation
1. Purpose
This module contains the core ViewModel layer for the DTS Viewer WPF application, implementing the MVVM pattern using Microsoft Prism and Unity. It provides the orchestration layer between the Views and the business logic, managing navigation regions, user notifications, and shell composition. The ViewModels handle view lifecycle (initialization, activation, cleanup), region management for dynamic view injection, and event-driven communication via IEventAggregator. This module serves as the structural backbone for the application's UI composition system.
2. Public Interface
NavigationViewModel
Inherits: BaseViewModel<INavigationViewModel>
Implements: INavigationViewModel
| Member | Signature | Description |
|---|---|---|
| Constructor | NavigationViewModel(INavigationView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer) |
Initializes the view model, sets DataContext, creates interaction requests, and subscribes to RaiseNotification event. |
| NavigationView | INavigationView { get; private set; } |
Holds reference to the associated view. |
| ContextNavigationRegion | object { get; set; } |
Gets/sets the content of the NavigationRegion on the view. Raises OnPropertyChanged("ContextNavigationRegion") on set. |
| HeaderInfo | string { get; } |
Returns hardcoded string "NavigationRegion". |
| Initialize | override void Initialize() |
Empty implementation. |
| Initialize | override void Initialize(object parameter) |
Casts parameter to IShellViewModel and assigns to Parent. |
| OnRaiseNotification | void OnRaiseNotification(NotificationContentEventArgs eventArgsWithTitle) |
Handles RaiseNotification events, transforms args and raises NotificationRequest. |
| IsBusy | bool { get; set; } |
Throws NotImplementedException. |
| IsDirty | bool { get; } |
Throws NotImplementedException. |
| Activated | override void Activated() |
Throws NotImplementedException. |
| Cleanup | override void Cleanup() |
Throws NotImplementedException. |
| CleanupAsync | Task CleanupAsync() |
Throws NotImplementedException. |
| InitializeAsync | override Task InitializeAsync() |
Throws NotImplementedException. |
| InitializeAsync | override Task InitializeAsync(object parameter) |
Throws NotImplementedException. |
MenuViewModel
Inherits: BaseViewModel<IMenuViewModel>
Implements: IMenuViewModel
| Member | Signature | Description |
|---|---|---|
| Constructor | MenuViewModel(IMenuView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer) |
Initializes the view model, sets DataContext, creates interaction requests, and subscribes to RaiseNotification event. |
| View | IMenuView { get; private set; } |
Holds reference to the associated view. |
| HeaderInfo | string { get; } |
Returns hardcoded string "MainRegion". |
| Initialize | override void Initialize() |
Contains placeholder code (int i = 10;). |
| Initialize | override void Initialize(object parameter) |
Casts parameter to IShellViewModel and assigns to Parent. |
| CreateViews | void CreateViews(Boolean initialize) |
Creates a ViewDefinition for RegionNames.MainRegion with IBaseView/IBaseViewModel types. Currently the _regionManager.AddView call is commented out. |
| OnRaiseNotification | void OnRaiseNotification(NotificationContentEventArgs eventArgsWithTitle) |
Handles RaiseNotification events. |
| IsBusy | bool { get; set; } |
Throws NotImplementedException. |
| IsDirty | bool { get; } |
Throws NotImplementedException. |
| Activated | override void Activated() |
Throws NotImplementedException. |
| Cleanup | override void Cleanup() |
Throws NotImplementedException. |
| CleanupAsync | Task CleanupAsync() |
Throws NotImplementedException. |
| InitializeAsync | override Task InitializeAsync() |
Throws NotImplementedException. |
| InitializeAsync | override Task InitializeAsync(object parameter) |
Throws NotImplementedException. |
ShellViewModel
Inherits: NotificationObject
Implements: IViewerShellViewModel
Attributes: [Export(typeof(IShellView))], [PartCreationPolicy(CreationPolicy.Shared)]
| Member | Signature | Description |
|---|---|---|
| Constructor | ShellViewModel(IViewerShellView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer) |
Initializes view, subscribes to RaiseNotification, registers IMainView→MainView and IMainViewModel→MainViewModel (singleton) with Unity. |
| View | IViewerShellView { get; private set; } |
Holds reference to the shell view. |
| ContextMainRegion | Object { get; set; } |
Gets/sets content of MainRegion from ShellView. Raises OnPropertyChanged("ContextMainRegion") on set. |
| IsMenuIncluded | bool { get; set; } |
Controls menu visibility. Raises OnPropertyChanged on set. |
| IsNavigationIncluded | bool { get; set; } |
Controls navigation visibility. Raises OnPropertyChanged on set. |
| HeaderInfo | string { get; } |
Returns hardcoded string "MainRegion". |
| GetRegions | List<FrameworkElement> GetRegions() |
Uses Utils.GetChildrenByName to find elements named "Region" in MainShell. |
| Initialize | void Initialize() |
Placeholder implementation (int i = 10;). |
| Initialize | void Initialize(object parameter) |
Placeholder implementation (int i = 22;). |
| Initialize | void Initialize(object parameter, object model) |
Empty implementation. |
| Activated | void Activated() |
Placeholder (var s = String.Empty;). |
| OnRaiseNotification | void OnRaiseNotification(NotificationContentEventArgs eventArgsWithTitle) |
Handles RaiseNotification events. |
| IsBusy | bool { get; } |
Throws NotImplementedException. |
| IsDirty | bool { get; } |
Throws NotImplementedException. |
| Cleanup | void Cleanup() |
Throws NotImplementedException. |
| CleanupAsync | Task CleanupAsync() |
Throws NotImplementedException. |
| InitializeAsync | Task InitializeAsync() |
Throws NotImplementedException. |
| InitializeAsync | Task InitializeAsync(object parameter) |
Throws NotImplementedException. |
ViewerShellViewModel
Inherits: NotificationObject
Implements: IViewerShellViewModel
Attributes: [Export(typeof(IShellView))], [PartCreationPolicy(CreationPolicy.Shared)]
| Member | Signature | Description |
|---|---|---|
| Constructor | ViewerShellViewModel(IViewerShellView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer) |
Initializes view, subscribes to RaiseNotification, registers IViewerMainView→ViewerMainView and IViewerMainViewModel→ViewerMainViewModel (singleton) with Unity. |
| View | IViewerShellView { get; private set; } |
Holds reference to the shell view. |
| ContextMainRegion | Object { get; set; } |
Gets/sets content of MainRegion from ViewerShellView. |
| IsMenuIncluded | bool { get; set; } |
Controls menu visibility. |
| IsNavigationIncluded | bool { get; set; } |
Controls navigation visibility. |
| IsBusy | bool { get; set; } |
Implemented - unlike other ViewModels, this has a backing field _isBusy and raises property changed. |
| HeaderInfo | string { get; } |
Returns hardcoded string "MainRegion". |
| GetRegions | List<FrameworkElement> GetRegions() |
Uses Utils.GetChildrenByName on ViewerShellView.MainShell. |
| Initialize | void Initialize() |
Placeholder (int i = 10;). |
| Initialize | void Initialize(object parameter) |
Placeholder (int i = 22;). |
| Initialize | void Initialize(object parameter, object model) |
Empty implementation. |
| Activated | void Activated() |
Placeholder (var s = String.Empty;). |
| OnRaiseNotification | void OnRaiseNotification(NotificationContentEventArgs eventArgsWithTitle) |
Handles RaiseNotification events. |
| IsDirty | bool { get; } |
Throws NotImplementedException. |
| Cleanup | void Cleanup() |
Throws NotImplementedException. |
| CleanupAsync | Task CleanupAsync() |
Throws NotImplementedException. |
| InitializeAsync | Task InitializeAsync() |
Throws NotImplementedException. |
| InitializeAsync | Task InitializeAsync(object parameter) |
Throws NotImplementedException. |
| OnPropertyChanged | void IBasePropertyChanged.OnPropertyChanged(string propertyName) |
Throws NotImplementedException. |
MainViewModel
Inherits: BaseViewModel<IMainViewModel>
Implements: IMainViewModel
| Member | Signature | Description |
|---|---|---|
| Constructor | MainViewModel(IMainView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer) |
Initializes view, subscribes to RaiseNotification and AssemblyListNotification events, registers IMenuView/IMenuViewModel and INavigationView/INavigationViewModel with Unity. |
| View | IMainView { get; private set; } |
Holds reference to the main view. |
| ContextMainRegion | object { get; set; } |
Currently returns null on get; setter raises OnPropertyChanged("ContextMainRegion") but content assignment is commented out. |
| IsMenuIncluded | bool { get; set; } |
Backed by _isMenuIncluded field. |
| IsNavigationIncluded | bool { get; set; } |
Backed by _isNavigationIncluded field. |
| HeaderInfo | string { get; } |
Returns hardcoded string "MainRegion". |
| Initialize | override void Initialize() |
Empty implementation. |
| Initialize | override void Initialize(object parameter) |
Casts to IViewerShellViewModel, sets Parent.IsMenuIncluded and Parent.IsNavigationIncluded, subscribes to AssemblyListNotification event with ThreadOption.PublisherThread. |
| Activated | override void Activated() |
Empty implementation. |
| OnAssemblyListChange | void OnAssemblyListChange(AssemblyListInfo e) |
Handler for AssemblyListNotification event. Entire implementation is commented out. |
| OnRaiseNotification | void OnRaiseNotification(NotificationContentEventArgs eventArgsWithTitle) |
Handles RaiseNotification events. |
3. Invariants
-
Constructor Pattern: All ViewModels must receive exactly four constructor parameters: the view interface,
IRegionManager,IEventAggregator, andIUnityContainer. The view'sDataContextis set tothiswithin the constructor. -
Event Subscription: All ViewModels subscribe to
RaiseNotificationevent viaEventAggregator.GetEvent<RaiseNotification>().Subscribe(OnRaiseNotification)during construction. -
Notification Transformation: The
OnRaiseNotificationhandler always transformsNotificationContentEventArgsto a new instance with(Message, MessageDetails, Image)before raising theNotificationRequest. -
Parent Assignment: The
Initialize(object parameter)method expectsparameterto be castable to eitherIShellViewModel(forNavigationViewModel,MenuViewModel) orIViewerShellViewModel(forMainViewModel). -
Region Naming Convention: Region content properties follow the naming pattern
Context{RegionName}Region(e.g.,ContextMainRegion,ContextNavigationRegion). -
HeaderInfo Consistency: All ViewModels return a hardcoded region name string from
HeaderInfo.
4. Dependencies
External Dependencies (Imports)
Microsoft.Practices.Prism.Events-IEventAggregator, event publishing/subscriptionMicrosoft.Practices.Prism.Interactivity.InteractionRequest-InteractionRequest<T>,Notification,ConfirmationMicrosoft.Practices.Prism.Regions-IRegionManagerMicrosoft.Practices.Prism.ViewModel-NotificationObjectMicrosoft.Practices.Unity-IUnityContainer,ContainerControlledLifetimeManagerSystem.ComponentModel.Composition- MEF attributes (Export,PartCreationPolicy,CreationPolicy)System.Windows-FrameworkElement(used inGetRegions())
Internal Dependencies (DTS.*)
DTS.Common.Base-BaseViewModel<T>,ViewDefinitionDTS.Common.Events-RaiseNotification,NotificationContentEventArgs,AssemblyListNotification,AssemblyListInfoDTS.Common.Interface-INavigationViewModel,IMenuViewModel,IShellViewModel,IViewerShellViewModel,IMainViewModel,IBaseViewModel,IBaseView,IBasePropertyChangedDTS.Common.Utils-Utils.GetChildrenByNameDTS.Common.Classes- Referenced inMenuViewModelDTS.Viewer.View-ShellView,ViewerShellView,MainView,MenuView,NavigationView,ViewerMainView
Dependency Graph
ShellViewModel / ViewerShellViewModel (root)
└── registers MainViewModel / ViewerMainViewModel
└── MainViewModel
└── registers MenuViewModel, NavigationViewModel
5. Gotchas
-
Stale XML Documentation: The XML comment in
NavigationViewModelconstructor references"TechnologyDoFrontEditViewModel"which does not match the actual class name. Similarly,MenuViewModelreferences"TechnologyDomainEditViewModel". These appear to be copy-paste artifacts from another codebase. -
Widespread NotImplementedException: The majority of lifecycle methods (
Activated,Cleanup,CleanupAsync,InitializeAsync,IsDirtygetter) throwNotImplementedExceptionacross all ViewModels. This indicates incomplete implementation—callers must not rely on these methods. -
Inconsistent IsBusy Implementation:
ShellViewModel.IsBusythrowsNotImplementedExceptionViewerShellViewModel.IsBusyis fully implemented with backing fieldNavigationViewModel.IsBusyandMenuViewModel.IsBusythrowNotImplementedException
This inconsistency suggests
ViewerShellViewModelis more complete thanShellViewModel. -
Commented-Out Critical Logic:
MainViewModel.OnAssemblyListChange()is entirely commented out—the method receivesAssemblyListInfobut does nothing with it.MainViewModel.ContextMainRegiongetter returnsnulland setter logic is commented out.MenuViewModel.CreateViews()has_regionManager.AddViewcall commented out.
-
new Keyword Hiding: Several members use
newto hide base class members:NavigationViewModel:PropertyChangedevent,OnPropertyChangedmethod,IsBusy,IsDirty,CleanupAsyncMenuViewModel:IsBusy,IsDirty,CleanupAsyncMainViewModel:IsMenuIncluded,IsNavigationIncluded
This may cause unexpected behavior when casting to base types.
-
Placeholder Code: Multiple
Initializemethods contain placeholder statements likeint i = 10;orvar s = String.Empty;that serve no functional purpose—likely debug artifacts. -
Duplicate Shell Implementations: Both
ShellViewModelandViewerShellViewModelimplementIViewerShellViewModeland have nearly identical structure. The relationship between these two classes is unclear from source alone—they may represent different shell configurations or be a refactoring in progress. -
ThreadOption.PublisherThread in Event Subscription: `