5.6 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-16T11:26:51.573043+00:00 | zai-org/GLM-5-FP8 | 1 | 4117e2f039d6caa8 |
ShellViewModel Documentation
1. Purpose
ShellViewModel serves as the main shell ViewModel for the DTS Viewer application loader. It acts as the primary orchestration layer for the application's UI shell, managing region navigation, notification/confirmation dialogs, and coordinating between the view layer and the Prism infrastructure (EventAggregator, RegionManager, UnityContainer). This class is the entry point for the shell's UI composition pattern, exposing regions for dynamic view injection and handling cross-component communication via events.
2. Public Interface
Constructor
public ShellViewModel(IShellView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer)
Initializes the shell ViewModel, sets the View's DataContext to itself, creates interaction requests, and subscribes to the RaiseNotification event.
Properties
| Property | Type | Description |
|---|---|---|
View |
IShellView |
The associated shell view instance. |
NotificationRequest |
InteractionRequest<Notification> |
Interaction request for displaying notification dialogs. |
ConfirmationRequest |
InteractionRequest<Confirmation> |
Interaction request for displaying confirmation dialogs. |
Width |
double |
Gets or sets the shell width. |
Height |
double |
Gets or sets the shell height. |
IsMenuIncluded |
bool |
Gets or sets whether the menu is included; raises PropertyChanged. |
IsNavigationIncluded |
bool |
Gets or sets whether navigation is included; raises PropertyChanged. |
HeaderInfo |
string |
Returns the constant string "MainRegion". |
IsBusy |
bool |
Gets or sets the busy indicator state. |
IsDirty |
bool |
Read-only; always returns false (no setter logic). |
ContextMainRegion |
Object |
Gets or sets the content of the MainRegion on the View; raises PropertyChanged on set. |
Methods
public void Initialize()
public void Initialize(object parameter)
public void Activated()
Empty implementations. No behavior executed.
public List<FrameworkElement> GetRegions()
Returns all FrameworkElements named "Region" within the MainShell of the ShellView by calling Utils.GetChildrenByName.
public void Cleanup()
public Task CleanupAsync()
public Task InitializeAsync()
public Task InitializeAsync(object parameter)
All throw NotImplementedException.
Events
public event PropertyChangedEventHandler PropertyChanged
Standard INotifyPropertyChanged implementation. Raised via private OnPropertyChanged(string propertyName) method.
3. Invariants
- Singleton Scope: The class is decorated with
[PartCreationPolicy(CreationPolicy.Shared)], ensuring a single shared instance per MEF container. - DataContext Binding: The View's
DataContextis always set to the ViewModel instance during construction. - Event Subscription: The ViewModel subscribes to
RaiseNotificationevent via_eventAggregator.GetEvent<RaiseNotification>().Subscribe(OnRaiseNotification)during construction. - View Casting: Methods
GetRegions()andContextMainRegionproperty assume theViewcan be cast toShellViewconcrete type.
4. Dependencies
This Module Depends On:
DTS.Common.Events—RaiseNotificationevent typeDTS.Common.Interface—IShellView,IViewerShellView,IViewerShellViewModelinterfacesDTS.Common.Utils—Utils.GetChildrenByNamestatic methodDTS.Common.Base— (imported but usage unclear from source)Microsoft.Practices.Prism.Events—IEventAggregatorMicrosoft.Practices.Prism.Interactivity.InteractionRequest—InteractionRequest<T>,Notification,ConfirmationMicrosoft.Practices.Prism.Regions—IRegionManagerMicrosoft.Practices.Prism.ViewModel— (likelyNotificationObjector similar base, though not used)Microsoft.Practices.Unity—IUnityContainerSystem.ComponentModel.Composition— MEF attributes
Consumers (Inferred):
- Any module resolving
IShellViewvia MEF container RaiseNotificationevent publishers (viaIEventAggregator)
5. Gotchas
-
NotImplementedException Methods:
Cleanup(),CleanupAsync(),InitializeAsync(), andInitializeAsync(object parameter)all throwNotImplementedException. Calling these will crash the application. -
Misleading XML Comment: The constructor's documentation states it "Creates a new instance of the TechnologyDomainEditViewModel" — this is incorrect; it creates a
ShellViewModel. -
Hardcoded View Cast:
GetRegions()andContextMainRegioncastViewto the concreteShellViewtype, violating MVVM separation. IfIShellViewis implemented by a different view type, runtimeInvalidCastExceptionwill occur. -
Dead Code:
LoadViewer()is defined but never called (commented out in constructor). It also castsIViewerShellViewtoShellView, which appears to be a bug —IViewerShellViewshould likely map to a different view type. -
IsDirty Property: The
IsDirtyproperty has no setter and always returnsfalse. It is unclear if this is intentional or incomplete. -
Missing Base Class: The commented-out inheritance (
//BaseViewModel<ShellViewModel>) suggests this class was refactored to not use a base ViewModel, but manually implementsINotifyPropertyChangedinstead.