Files
DP44/enriched-partialglm/DTS Viewer/DTS.Viewer.Loader/ViewModel.md
2026-04-17 14:55:32 -04:00

5.6 KiB

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DTS Viewer/DTS.Viewer.Loader/ViewModel/ShellViewModel.cs
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

  1. Singleton Scope: The class is decorated with [PartCreationPolicy(CreationPolicy.Shared)], ensuring a single shared instance per MEF container.
  2. DataContext Binding: The View's DataContext is always set to the ViewModel instance during construction.
  3. Event Subscription: The ViewModel subscribes to RaiseNotification event via _eventAggregator.GetEvent<RaiseNotification>().Subscribe(OnRaiseNotification) during construction.
  4. View Casting: Methods GetRegions() and ContextMainRegion property assume the View can be cast to ShellView concrete type.

4. Dependencies

This Module Depends On:

  • DTS.Common.EventsRaiseNotification event type
  • DTS.Common.InterfaceIShellView, IViewerShellView, IViewerShellViewModel interfaces
  • DTS.Common.UtilsUtils.GetChildrenByName static method
  • DTS.Common.Base — (imported but usage unclear from source)
  • Microsoft.Practices.Prism.EventsIEventAggregator
  • Microsoft.Practices.Prism.Interactivity.InteractionRequestInteractionRequest<T>, Notification, Confirmation
  • Microsoft.Practices.Prism.RegionsIRegionManager
  • Microsoft.Practices.Prism.ViewModel — (likely NotificationObject or similar base, though not used)
  • Microsoft.Practices.UnityIUnityContainer
  • System.ComponentModel.Composition — MEF attributes

Consumers (Inferred):

  • Any module resolving IShellView via MEF container
  • RaiseNotification event publishers (via IEventAggregator)

5. Gotchas

  1. NotImplementedException Methods: Cleanup(), CleanupAsync(), InitializeAsync(), and InitializeAsync(object parameter) all throw NotImplementedException. Calling these will crash the application.

  2. Misleading XML Comment: The constructor's documentation states it "Creates a new instance of the TechnologyDomainEditViewModel" — this is incorrect; it creates a ShellViewModel.

  3. Hardcoded View Cast: GetRegions() and ContextMainRegion cast View to the concrete ShellView type, violating MVVM separation. If IShellView is implemented by a different view type, runtime InvalidCastException will occur.

  4. Dead Code: LoadViewer() is defined but never called (commented out in constructor). It also casts IViewerShellView to ShellView, which appears to be a bug — IViewerShellView should likely map to a different view type.

  5. IsDirty Property: The IsDirty property has no setter and always returns false. It is unclear if this is intentional or incomplete.

  6. Missing Base Class: The commented-out inheritance (//BaseViewModel<ShellViewModel>) suggests this class was refactored to not use a base ViewModel, but manually implements INotifyPropertyChanged instead.