8.9 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||||
|---|---|---|---|---|---|---|---|---|
|
2026-04-16T10:58:04.030267+00:00 | zai-org/GLM-5-FP8 | 1 | d7175f2d8133b4b4 |
DTS.Viewer.Loader Module Documentation
1. Purpose
The DTS.Viewer.Loader module serves as the entry point and bootstrapping layer for a Prism-based WPF viewer application. Its primary role is to initialize the Unity dependency injection container, configure module discovery via directory-based cataloging, and orchestrate the startup of the main viewer session. This module acts as the composition root that wires together the shell view, region management, and dynamically loaded plugins.
2. Public Interface
App (partial class, inherits Application)
File: App.xaml.cs
| Member | Signature | Description |
|---|---|---|
App_OnStartup |
private void App_OnStartup(object sender, StartupEventArgs e) |
Application startup event handler. Instantiates a ViewerLoaderSession and calls CreateSession() to initialize the application. |
MainWindow (partial class, inherits Window)
File: MainWindow.xaml.cs
| Member | Signature | Description |
|---|---|---|
| Constructor | public MainWindow() |
Calls InitializeComponent(). Standard WPF window initialization. |
ViewerLoaderSession
File: ViewerLoaderSession.cs
| Member | Signature | Description |
|---|---|---|
_unityContainer |
public IUnityContainer _unityContainer { get; private set; } |
Exposes the Unity dependency injection container after session creation. |
ServiceLocator |
public IServiceLocator ServiceLocator { get; private set; } |
Exposes the Prism service locator. |
EventAggregator |
public IEventAggregator EventAggregator { get; private set; } |
Exposes the Prism event aggregator for pub/sub messaging. |
RegionManager |
public IRegionManager RegionManager { get; private set; } |
Exposes the Prism region manager for view composition. |
| Constructor | public ViewerLoaderSession() |
Default constructor. No initialization performed. |
CreateSession |
public void CreateSession() |
Main initialization method. Creates the bootstrapper, resolves core services from the container, starts the viewer module, and sets the main region context on the shell viewmodel. |
Terminate |
public void Terminate() |
Called during application shutdown. Currently empty implementation. |
GetRegisteredViewType |
private Type GetRegisteredViewType(string name) |
Queries the Unity container registrations for a registered type matching the given name suffix. Returns the first match or default. |
LoadPlugins |
private List<Assembly> LoadPlugins() |
Uses PluginManager.GetPluginManager() to load plugin assemblies implementing IModule from a configuration file path. |
Bootstrapper (inherits UnityBootstrapper)
File: Bootstrapper.cs
| Member | Signature | Description |
|---|---|---|
_serviceLocator |
public IServiceLocator _serviceLocator { get; private set; } |
Exposes the resolved service locator instance. |
_EventAggregator |
public IEventAggregator _EventAggregator { get; private set; } |
Exposes the resolved event aggregator instance. |
ConfigureContainer |
protected override void ConfigureContainer() |
Registers IShellView → ShellView and IShellViewModel → ShellViewModel (singleton) with the Unity container, then calls base implementation. |
ConfigureRegionAdapterMappings |
protected override RegionAdapterMappings ConfigureRegionAdapterMappings() |
Returns null. Region adapter configuration is intentionally disabled to avoid interfering with the viewer app's mappings. |
CreateShell |
protected override DependencyObject CreateShell() |
Resolves the shell viewmodel, initializes it, attaches a closing event handler, and returns the ShellView instance. |
CreateModuleCatalog |
protected override IModuleCatalog CreateModuleCatalog() |
Returns a new AggregateModuleCatalog instance for aggregating multiple module catalogs. |
ConfigureModuleCatalog |
protected override void ConfigureModuleCatalog() |
Creates a DirectoryModuleCatalog using the plugin folder path from Properties.Settings.Default.PluginFolder and adds it to the aggregate catalog. |
InitializeModules |
protected override void InitializeModules() |
Registers IDTSRegionManager → DTSRegionManager as a singleton, then calls base initialization. |
Bootstrapper_Closing |
void Bootstrapper_Closing(object sender, CancelEventArgs e) |
Event handler for shell closing; calls Application.Current.Shutdown(1). |
3. Invariants
-
Bootstrapper Singleton Pattern: The
_bootstrapperfield inViewerLoaderSessionmust only be created once. TheCreateBootstrapper()method checks for null before instantiation and throws if creation fails. -
Container Availability: The
_unityContainer,ServiceLocator,EventAggregator, andRegionManagerproperties onViewerLoaderSessionare only valid afterCreateSession()has been successfully called and_bootstrapperis non-null. -
Shell ViewModel Lifetime:
ShellViewModelis registered withContainerControlledLifetimeManager, making it a singleton within the container. -
Module Path Configuration: The module catalog depends on
Properties.Settings.Default.PluginFolderbeing correctly configured; otherwise, module discovery will fail. -
Region Adapter Mappings:
ConfigureRegionAdapterMappings()returnsnullby design—this is intentional to prevent interference with the viewer application's existing region adapters.
4. Dependencies
External Dependencies (Imports)
| Namespace | Purpose |
|---|---|
DTS.Common |
Common utilities and types |
DTS.Common.Base |
Base classes |
DTS.Common.Classes |
Common class implementations |
DTS.Common.Core.PluginLib |
Plugin management infrastructure (PluginManager, IModule) |
DTS.Common.Interface |
Core interfaces (IShellView, IShellViewModel, IShellViewModel, IViewerModule, IViewerMainViewModel, IDTSRegionManager) |
Microsoft.Practices.Prism.Events |
IEventAggregator for event aggregation |
Microsoft.Practices.Prism.Modularity |
IModuleCatalog, DirectoryModuleCatalog, AggregateModuleCatalog |
Microsoft.Practices.Prism.Regions |
IRegionManager, RegionAdapterMappings |
Microsoft.Practices.Prism.UnityExtensions |
UnityBootstrapper base class |
Microsoft.Practices.ServiceLocation |
IServiceLocator |
Microsoft.Practices.Unity |
IUnityContainer, ContainerControlledLifetimeManager, InjectionMember |
System.Windows |
WPF core types (Application, Window, DependencyObject, Visibility) |
Internal Dependencies
ShellViewandShellViewModelare resolved via Unity but their definitions are not included in the provided source files.DTSRegionManageris referenced but not defined in the provided source.
5. Gotchas
-
Hardcoded Configuration Path: In
ViewerLoaderSession.CreateSession(), the path@"C:\devDTS\RunTimeModules\DTS.Viewer.dll.config"is hardcoded in the call toviewerModule.StartSession(). This will likely fail on machines without this specific directory structure. -
SynchronizationLockException Swallowed: In
Bootstrapper.ConfigureContainer(), theSystem.Threading.SynchronizationLockExceptionis caught but has an empty catch block with no logging or handling. This may mask threading issues. -
Bootstrapper Cannot Be Re-created: As documented in the remarks on
_bootstrapper, once modules are loaded into theDirectoryModuleCatalog, module initializers will not be called again on subsequent bootstrapper creations. The bootstrapper loads approximately 40 MB into memory and cannot be fully unloaded without additional effort. -
Commented-Out Code Blocks:
ViewerLoaderSession.CreateSession()contains significant commented-out code related to plugin loading and view registration, suggesting incomplete refactoring or alternative implementation paths that were abandoned. -
Region Adapter Mappings Disabled: The
ConfigureRegionAdapterMappings()override returnsnulland has commented-out code forStackPanelRegionAdapter. This may cause issues if region adapters are expected by other modules. -
Application Shutdown Code: The
Bootstrapper_Closinghandler callsApplication.Current.Shutdown(1)with exit code 1, which typically indicates an error condition. This may be unintentional. -
Null Check After Creation:
CreateBootstrapper()has a redundant null check after the try-catch block—the exception handling re-throws, so if execution reaches the second null check, the bootstrapper should always be non-null unless there's a race condition.