10 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||||
|---|---|---|---|---|---|---|---|---|---|
|
2026-04-16T13:36:04.363120+00:00 | zai-org/GLM-5-FP8 | 1 | f841428d718c70bf |
DTS.Viewer Module Documentation
1. Purpose
The DTS.Viewer namespace provides the core infrastructure for a modular, Prism-based WPF viewer application. It implements a plugin architecture using Unity dependency injection and Prism's modularity framework. The module manages application bootstrapping, session lifecycle, region management, and dynamic plugin loading. It supports both standalone and embedded operational modes, allowing the viewer to function as an independent application or as a component within a larger host system.
2. Public Interface
Settings (DTS.Viewer.Properties)
internal sealed partial class Settings
- Settings() - Default constructor. Contains commented-out event handler registrations.
- SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) - Private method stub for handling setting change events.
- SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) - Private method stub for handling settings save events.
ExportModule
[Module(ModuleName = "Export")]
public class ExportModule : IExportModule
- ExportModule(IUnityContainer unityContainer) - Constructor accepting an injected
IUnityContainer. - bool SessionStarted { get; private set; } - Property indicating whether a session has been started.
- void Initialize() - Registers
IExportModuletoExportModulewith container-controlled lifetime. - void StartSession() - Resolves
IEventAggregatorand publishesLoadExportModuleEventwithLoadExportModuleArg; setsSessionStartedtotrue. - void RegisterTypes(IContainerRegistry containerRegistry) - Calls
Initialize(). - void OnInitialized(IContainerProvider containerProvider) - Empty implementation.
ExportNameAttribute
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
public class ExportNameAttribute : TextAttribute
- ExportNameAttribute() - Default constructor; sets internal
_assemblyNameto"Export". - ExportNameAttribute(string s) - Overloaded constructor; ignores parameter and sets
_assemblyNameto"Export". - string AssemblyName { get; } - Returns
_assemblyName. - Type GetAttributeType() - Returns
typeof(TextAttribute). - string GetAssemblyName() - Returns
AssemblyName.
ViewerModule
[Module(ModuleName = "Viewer")]
public class ViewerModule : IViewerModule
- ViewerModule(IUnityContainer unityContainer) - Constructor accepting an injected
IUnityContainer. - bool SessionStarted { get; private set; } - Property indicating whether a session has been started.
- void Initialize() - Registers
IViewerModuletoViewerModulewith container-controlled lifetime. - void StartSession() - Resolves
IEventAggregatorand publishesLoadViewModulEventwithLoadViewModulArg; setsSessionStartedtotrue. - void RegisterTypes(IContainerRegistry containerRegistry) - Calls
Initialize(). - void OnInitialized(IContainerProvider containerProvider) - Empty implementation.
ViewerNameAttribute
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]
public class ViewerNameAttribute : TextAttribute
- ViewerNameAttribute() - Default constructor; sets internal
_assemblyNameto"Viewer". - ViewerNameAttribute(string s) - Overloaded constructor; ignores parameter and sets
_assemblyNameto"Viewer". - string AssemblyName { get; } - Returns
_assemblyName. - Type GetAttributeType() - Returns
typeof(TextAttribute). - string GetAssemblyName() - Returns
AssemblyName.
ViewerSession
public class ViewerSession
- ViewerSession() - Empty constructor.
- IUnityContainer Container { get; private set; } - Exposes the Unity container from the bootstrapper.
- IServiceLocator _serviceLocator { get; private set; } - Exposes the service locator.
- IEventAggregator _eventAggregator { get; private set; } - Exposes the event aggregator.
- IRegionManager _regionManager { get; private set; } - Exposes the region manager.
- string CustomConfigPath { get; set; } - Gets or sets a custom configuration path.
- void CreateSession(bool standalone, string customConfigPath = "") - Creates the bootstrapper, resolves core services, loads plugins via
PluginManager, and publishesAssemblyListNotificationViewerevent. - void Terminate() - Empty method intended for shutdown cleanup.
Bootstrapper
public class Bootstrapper : UnityBootstrapper
- Bootstrapper(bool standalone, string customConfigPath = "") - Constructor accepting standalone mode flag and optional custom config path.
- bool Standalone { get; set; } - Indicates whether the application runs in standalone mode.
- string CustomConfigPath { get; set; } - Custom configuration path.
- IServiceLocator _ServiceLocator { get; private set; } - Resolved service locator.
- IEventAggregator _EventAggregator { get; private set; } - Resolved event aggregator.
- void ConfigureContainer() - Overrides base to register
IViewerMainViewGrid,IViewerMainViewModel, and callsbase.ConfigureContainer(). - RegionAdapterMappings ConfigureRegionAdapterMappings() - Registers region adapters for
Selector,ItemsControl,ContentControl, and conditionallyStackPanel(standalone only). - DependencyObject CreateShell() - Creates the main shell, registers regions, initializes the view model, and returns the view.
- IModuleCatalog CreateModuleCatalog() - Returns resolved
IModuleCatalogor newAggregateModuleCatalog. - void ConfigureModuleCatalog() - For standalone mode only, reads plugin folders from configuration and adds a
DirectoryModuleCatalog. - void InitializeModules() - For standalone mode only, registers
IDTSViewRegionManagertoDTSViewRegionManagerand callsbase.InitializeModules().
3. Invariants
-
Bootstrapper Singleton: The
_bootstrapperfield inViewerSessionshould only be created once. Re-creation is explicitly discouraged in comments due to module loading behavior. -
Module Self-Registration: Both
ExportModuleandViewerModuleregister themselves as implementations of their respective interfaces duringInitialize()/RegisterTypes(). -
Standalone Mode Controls Behavior:
ConfigureModuleCatalog()only adds directory modules whenStandaloneistrue.InitializeModules()only executes whenStandaloneistrue.StackPanelRegionAdapteris only registered whenStandaloneistrue.
-
Region Registration Safety: In
CreateShell(), regions are only added if they don't already exist (ContainsRegionWithNamecheck). -
Attribute Constructor Parameter Ignored: Both
ExportNameAttributeandViewerNameAttributeignore the string parametersin their constructors, always returning hardcoded values.
4. Dependencies
External Dependencies (Imports)
- Prism Framework:
Prism.Events,Prism.Ioc,Prism.Modularity- Module system and dependency injection. - Unity Container:
Unity,Unity.Lifetime- IoC container implementation. - Microsoft.Practices (Legacy Prism):
Microsoft.Practices.Prism.Events,Microsoft.Practices.Prism.Modularity,Microsoft.Practices.Prism.Regions,Microsoft.Practices.Prism.UnityExtensions,Microsoft.Practices.ServiceLocation,Microsoft.Practices.Unity- Legacy Prism APIs used inViewerSessionandBootstrapper. - System.Configuration: Application configuration handling.
- System.ComponentModel.Composition.Hosting: MEF composition support (used for
DirectoryModuleCatalog).
Internal Dependencies (Inferred)
- DTS.Common.Events:
LoadExportModuleEvent,LoadExportModuleArg,LoadViewModulEvent,LoadViewModulArg,AssemblyListNotificationViewer,AssemblyListInfo. - DTS.Common.Interface:
IExportModule,IViewerModule,IViewerMainViewGrid,IViewerMainViewModel,IShellViewModel,IDTSViewRegionManager. - DTS.Common.Base:
TextAttribute. - DTS.Common.Core.PluginLib:
PluginManager,PluginConfigSectionHandler,FilterHashElement. - DTS.Common: General utilities.
Consumers
- The module appears designed to be consumed by a host application (referenced as "JMPS" in comments) or run standalone.
5. Gotchas
-
Mixed Prism Versions: The codebase uses both modern Prism namespaces (
Prism.*) and legacy Microsoft.Practices namespaces (Microsoft.Practices.Prism.*). This mixing of versions could cause compatibility issues or confusion. -
Bootstrapper Memory Footprint: Comments indicate the bootstrapper loads ~40 MB into memory and cannot be easily unloaded. The comment explicitly warns: "Do not try to re-create the bootstrapper."
-
Attribute Constructor Parameter Ignored: The
ExportNameAttribute(string s)andViewerNameAttribute(string s)constructors accept a parameter that is completely ignored. The_assemblyNameis always set to a hardcoded value regardless of input. -
Empty Event Handlers: The
Settingsclass has empty event handler stubs that do nothing. The constructor has commented-out code to wire these up. -
Try-Catch Swallowing in ConfigureRegionAdapterMappings: Region adapter registrations are wrapped in empty try-catch blocks that silently ignore failures.
-
Exception Handling in CreateShell: The
CreateShell()method catches all exceptions, stores the message in a local variablesthat is never used, and returnsnull. This silently suppresses errors. -
Non-Stand-alone Module Initialization: When
Standaloneisfalse,InitializeModules()returns early without registeringIDTSViewRegionManageror callingbase.InitializeModules(). This may leave modules uninitialized. -
Commented-Out Code in ConfigureContainer: There is significant commented-out code regarding conditional view registration based on
Standalonemode, suggesting incomplete refactoring. -
Redundant Resolver Calls: In
CreateShell(),Containeris resolved fromServiceLocator.Currentdespite already being available via inheritance fromUnityBootstrapper.