5.8 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-16T14:06:17.211050+00:00 | zai-org/GLM-5-FP8 | 1 | 4117e2f039d6caa8 |
Documentation: ShellViewModel.cs
1. Purpose
The ShellViewModel class serves as the main view model (or "Shell") for the DTS.Viewer.Loader module. It acts as the primary orchestrator for the application's UI shell, responsible for setting the data context on the associated IShellView, managing region navigation via the IRegionManager, and handling global application events (specifically notifications) via the IEventAggregator. It exposes properties to control UI layout elements like menu and navigation visibility and provides interaction requests for pop-up dialogs.
2. Public Interface
Constructor
ShellViewModel(IShellView view, IRegionManager regionManager, IEventAggregator eventAggregator, IUnityContainer unityContainer)
Initializes the ViewModel. It sets the View's DataContext to itself, initializes InteractionRequest objects, and subscribes to the RaiseNotification event.
Properties
View(IShellView): Gets the associated View instance.NotificationRequest(InteractionRequest<Notification>): Used to trigger notification pop-ups in the UI.ConfirmationRequest(InteractionRequest<Confirmation>): Used to trigger confirmation dialogs in the UI.ContextMainRegion(Object): Gets or sets the content of theMainRegioncontrol on the View. TriggersOnPropertyChangedwhen set.Width/Height(double): Get or set the dimensions of the shell.IsMenuIncluded(bool): Gets or sets a value indicating whether the menu is included. Notifies the view on change.IsNavigationIncluded(bool): Gets or sets a value indicating whether navigation is included. Notifies the view on change.HeaderInfo(string): Returns the hardcoded string "MainRegion".IsBusy(bool): Property intended to track busy state (no logic observed).IsDirty(bool): Read-only property (returns defaultfalse).
Methods
void Initialize(): Empty implementation.void Initialize(object parameter): Empty implementation.void Activated(): Empty implementation.List<FrameworkElement> GetRegions(): Returns a list ofFrameworkElementobjects named "Region" found within theMainShellof theShellView.void Cleanup(): ThrowsNotImplementedException.Task CleanupAsync(): ThrowsNotImplementedException.Task InitializeAsync(): ThrowsNotImplementedException.Task InitializeAsync(object parameter): ThrowsNotImplementedException.
3. Invariants
- View-ViewModel Binding: Upon construction, the
View.DataContextis immediately assigned to theShellViewModelinstance (this). - Event Subscription: The ViewModel is always subscribed to the
RaiseNotificationevent via theIEventAggregatorupon instantiation. - Concrete View Casting: The
GetRegionsandContextMainRegionmembers rely on casting theIShellViewinterface to the concreteShellViewclass. Therefore, the injectedviewargument must be an instance of (or inherit from)DTS.Viewer.Loader.ShellView. - MEF Registration: The class is exported as
IShellViewwith aSharedcreation policy, meaning the container will manage a singleton instance of this ViewModel.
4. Dependencies
External Dependencies
- Microsoft.Practices.Prism.Events: Uses
IEventAggregatorfor event handling. - Microsoft.Practices.Prism.Interactivity.InteractionRequest: Uses
InteractionRequest,Notification, andConfirmationfor UI dialogs. - Microsoft.Practices.Prism.Regions: Uses
IRegionManagerfor region management. - Microsoft.Practices.Unity: Uses
IUnityContainerfor dependency resolution. - System.ComponentModel.Composition: Uses MEF attributes (
[Export],[PartCreationPolicy]).
Internal Dependencies
- DTS.Common.Events: References
RaiseNotificationevent andNotificationContentEventArgs. - DTS.Common.Interface: References
IShellView,IViewerShellView,IViewerShellViewModel. - DTS.Common.Utils: References static
Utils.GetChildrenByNamemethod. - DTS.Viewer.Loader (ShellView): Explicitly casts the interface to this concrete class to access
MainShellandMainRegion.
5. Gotchas
- NotImplementedExceptions: The methods
Cleanup,CleanupAsync,InitializeAsync, andInitializeAsync(object parameter)all throwNotImplementedException. Calling these methods will crash the application. - Broken Abstraction: The code explicitly casts the
IShellViewinterface to the concreteShellViewclass inGetRegions,ContextMainRegion, andLoadViewer. This defeats the purpose of the interface and will cause anInvalidCastExceptionif a different implementation ofIShellViewis injected. - Suspicious MEF Export: The class is exported as
[Export(typeof(IShellView))], but the class itself implementsIShellViewModel. This suggests the ViewModel is being registered as the View interface, which is unconventional and potentially a bug. - Dead Code: The method
LoadViewer()is commented out in the constructor but exists in the codebase. It attempts to resolveIViewerShellViewandIViewerShellViewModeland manually set visibility, but it also castsIViewerShellViewtoShellView, which may be incorrect ifIViewerShellViewis a different control. - Manual INPC: The class manually implements
INotifyPropertyChangedrather than inheriting from a base class (commented outBaseViewModel<ShellViewModel>), yet it importsMicrosoft.Practices.Prism.ViewModel. This suggests a partial refactoring or inconsistent coding standards.