5.8 KiB
5.8 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||||
|---|---|---|---|---|---|---|---|---|
|
2026-04-16T13:36:22.431378+00:00 | zai-org/GLM-5-FP8 | 1 | d7175f2d8133b4b4 |
Documentation: DTS.Viewer.Loader
1. Purpose
The DTS.Viewer.Loader assembly serves as the initialization and bootstrapping layer for a WPF-based DTS Viewer application. It leverages the Microsoft Prism framework (specifically UnityBootstrapper) to configure dependency injection, dynamically load runtime modules from a predefined directory, and initialize the primary application shell (ShellView) and viewer session. Its role is to act as the entry point that orchestrates the composition of the UI and backend services before handing control over to the loaded modules.
2. Public Interface
Class: App (inherits Application)
App_OnStartup(object sender, StartupEventArgs e): Private event handler for the application startup. It instantiatesViewerLoaderSessionand invokesCreateSession()to initialize the application logic.
Class: MainWindow (inherits Window)
MainWindow(): Constructor. CallsInitializeComponent(). Note: Based onBootstrapperlogic, this window appears to be unused in the main startup flow, which favorsShellView.
Class: ViewerLoaderSession
CreateSession(): Public method that initializes the Prism infrastructure. It creates theBootstrapper, resolves theIUnityContainer,IEventAggregator,IServiceLocator, andIRegionManager, and then starts the viewer session viaIViewerModule.Terminate(): Public method intended for shutdown/cleanup logic (currently empty implementation).- Properties:
_unityContainer(IUnityContainer): Provides access to the Unity dependency injection container.ServiceLocator(IServiceLocator): Provides access to the service locator abstraction.EventAggregator(IEventAggregator): Provides access to the Prism event aggregation system.RegionManager(IRegionManager): Manages the visual regions of the application.
Class: Bootstrapper (inherits UnityBootstrapper)
ConfigureContainer(): Override that registersIShellViewandIShellViewModelwith the Unity container.CreateShell(): Override that resolves the shell view model, initializes the view, sets its data context, and returns theShellViewinstance.CreateModuleCatalog(): Override that initializes anAggregateModuleCatalog.ConfigureModuleCatalog(): Override that adds aDirectoryModuleCatalogpointing to the plugin folder defined in settings.InitializeModules(): Override that registersIDTSRegionManageras a singleton and initializes modules.
3. Invariants
- Singleton ViewModels:
IShellViewModelis registered with aContainerControlledLifetimeManager, ensuring only one instance of the Shell ViewModel exists during the application lifetime. - Region Adapter Mappings: The
ConfigureRegionAdapterMappingsmethod is explicitly overridden to returnnull. This implies that region adapters must be defined elsewhere or are not used/required by the shell initialization logic in this specific bootstrapper. - Module Loading Location: Modules are strictly loaded from the directory specified in
Properties.Settings.Default.PluginFolder. - Shell Initialization: The
CreateShellmethod requiresIShellViewModelto be resolvable; otherwise, it returns a genericDependencyObject(which effectively results in no main window being shown).
4. Dependencies
External Dependencies
- Microsoft.Practices.Prism: Specifically
Events,Modularity,Regions, andUnityExtensions. - Microsoft.Practices.Unity: Used for Dependency Injection (
IUnityContainer,ContainerControlledLifetimeManager). - Microsoft.Practices.ServiceLocation: Used for the
IServiceLocatorabstraction. - System.Windows: WPF core libraries for
Application,Window,DependencyObject.
Internal Dependencies
- DTS.Common: Referenced in
ViewerLoaderSession. - DTS.Common.Base: Referenced in
ViewerLoaderSession. - DTS.Common.Classes: Referenced in
ViewerLoaderSession. - DTS.Common.Core.PluginLib: Used for
PluginManagerandIModule. - DTS.Common.Interface: Used for interfaces such as
IShellView,IShellViewModel,IViewerModule,IViewerMainViewModel,IDTSRegionManager.
5. Gotchas
- Hardcoded Configuration Path: In
ViewerLoaderSession.CreateSession(), the path@"C:\devDTS\RunTimeModules\DTS.Viewer.dll.config"is hardcoded as an argument toviewerModule.StartSession. This will likely cause the application to fail on machines without this specific directory structure. - Swallowed Exception:
Bootstrapper.ConfigureContainer()catchesSystem.Threading.SynchronizationLockExceptioninside atry/catchblock with an empty catch body. This suppresses a potential threading error which could mask underlying race conditions. - Unused MainWindow: The project contains a
MainWindowclass, but theBootstrapper.CreateShell()method explicitly creates and shows aShellView. TheMainWindowappears to be dead code or a legacy artifact. - Memory Constraints: The source code comments in
ViewerLoaderSessionexplicitly warn against re-creating the bootstrapper, noting that it loads ~40MB into memory and cannot be easily unloaded. - Application Exit Code: The
Bootstrapper_Closingevent handler callsApplication.Current.Shutdown(1), passing an exit code of1, which conventionally indicates an error or abnormal termination, even though this is the standard closing flow.