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

6.7 KiB

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.ViewerSettings/ViewerSettingsModule.cs
2026-04-16T11:05:22.275750+00:00 zai-org/GLM-5-FP8 1 9f0f5c6b474b7ca8

Documentation: ViewerSettingsModule

1. Purpose

This module serves as the Prism module definition for the ViewerSettings feature within the DTS Viewer application. It is responsible for registering the ViewerSettings View and ViewModel with the Unity dependency injection container, and providing assembly-level metadata (name, image, group, and region) that enables the main application to discover and display this module as an available component. The module belongs to the "Viewer" assembly group and targets the "ViewerSettingsRegion" for UI composition.


2. Public Interface

ViewerSettingsModule (class)

Implements Prism.Modularity.IModule. The primary module entry point for the ViewerSettings feature.

Member Signature Description
Constructor ViewerSettingsModule(IUnityContainer unityContainer) Accepts a Unity container instance via dependency injection and stores it in _unityContainer.
RegisterTypes void RegisterTypes(IContainerRegistry containerRegistry) Calls Initialize() to perform type registrations.
OnInitialized void OnInitialized(IContainerProvider containerProvider) Empty implementation; no post-registration logic executed.
Initialize void Initialize() Registers IViewerSettingsViewViewerSettingsView and IViewerSettingsViewModelViewerSettingsViewModel with Unity. A commented-out registration for IViewerSettingsModel exists but is not active.

ViewerSettingsModuleNameAttribute (class)

Extends DTS.Common.Interface.TextAttribute. Assembly-level attribute providing the module's name.

Member Signature Description
Constructor ViewerSettingsModuleNameAttribute() Default constructor; sets AssemblyName to AssemblyNames.ViewerSettings.ToString().
Constructor ViewerSettingsModuleNameAttribute(string s) Overload accepting a string parameter (unused).
AssemblyName override string AssemblyName { get; } Returns AssemblyNames.ViewerSettings.ToString().
GetAttributeType override Type GetAttributeType() Returns typeof(TextAttribute).
GetAssemblyName override string GetAssemblyName() Returns the AssemblyName property value.

ViewerSettingsModuleImageAttribute (class)

Extends DTS.Common.Interface.ImageAttribute. Assembly-level attribute providing the module's image, name, group, and region metadata.

Member Signature Description
Constructor ViewerSettingsModuleImageAttribute() Default constructor; initializes _img via AssemblyInfo.GetImage().
Constructor ViewerSettingsModuleImageAttribute(string s) Overload accepting a string parameter (unused).
AssemblyImage override BitmapImage AssemblyImage { get; } Lazy-loads and returns the module's image via AssemblyInfo.GetImage(AssemblyNames.ViewerSettings.ToString()).
AssemblyName override string AssemblyName { get; } Returns AssemblyNames.ViewerSettings.ToString().
AssemblyGroup override string AssemblyGroup { get; } Returns eAssemblyGroups.Viewer.ToString().
AssemblyRegion override eAssemblyRegion AssemblyRegion { get; } Returns eAssemblyRegion.ViewerSettingsRegion.
GetAttributeType override Type GetAttributeType() Returns typeof(ImageAttribute).
GetAssemblyImage override BitmapImage GetAssemblyImage() Returns AssemblyImage.
GetAssemblyName override string GetAssemblyName() Returns AssemblyName.
GetAssemblyGroup override string GetAssemblyGroup() Returns AssemblyGroup.
GetAssemblyRegion override eAssemblyRegion GetAssemblyRegion() Returns AssemblyRegion.

3. Invariants

  • Module Registration: IViewerSettingsView must always resolve to ViewerSettingsView, and IViewerSettingsViewModel must always resolve to ViewerSettingsViewModel after the module is loaded.
  • Assembly Attributes: Both ViewerSettingsModuleNameAttribute and ViewerSettingsModuleImageAttribute are applied at assembly level with AllowMultiple = false, ensuring exactly one instance of each per assembly.
  • Region Assignment: The module is always associated with eAssemblyRegion.ViewerSettingsRegion.
  • Group Assignment: The module always belongs to eAssemblyGroups.Viewer.

4. Dependencies

This Module Depends On:

  • Prism.ModularityIModule interface for module lifecycle.
  • Prism.IocIContainerProvider, IContainerRegistry for DI registration.
  • UnityIUnityContainer for Unity-specific DI operations.
  • System.Windows.Media.ImagingBitmapImage for module imagery.
  • DTS.CommonAssemblyNames enum (inferred from usage).
  • DTS.Common.InterfaceTextAttribute, ImageAttribute base classes; eAssemblyGroups, eAssemblyRegion enums; AssemblyInfo static class (inferred from usage).

What Depends On This Module:

  • Main DTS Viewer Application — Loads this module dynamically via Prism's module catalog; uses the assembly attributes to display the module in available components list and navigate to the appropriate region.

5. Gotchas

  1. Misleading Singleton Comment: The comment on line 35 states "Register View & View-Model... as a singleton," but _unityContainer.RegisterType<TFrom, TTo>() without an explicit ContainerControlledLifetimeManager registers types as transient, not singleton. Either the comment is incorrect, or the implementation is missing the lifetime manager.

  2. Non-standard Initialization Pattern: Initialize() is invoked from RegisterTypes(), while OnInitialized() is empty. The typical Prism pattern is to register types in RegisterTypes() and perform post-registration initialization in OnInitialized(). This conflation may cause confusion.

  3. Unused Constructor Parameter: Both attribute classes have constructors accepting a string s parameter that is never used. This appears to be a requirement for attribute syntax compatibility, but its purpose is unclear from source alone.

  4. Redundant Image Initialization: In ViewerSettingsModuleImageAttribute, _img is assigned in both the constructor and the AssemblyImage property getter. The property getter reassigns _img on every access, which is redundant after the first call.

  5. Commented-Out Model Registration: Line 39 contains a commented registration for IViewerSettingsModel. It is unclear whether this represents incomplete work, a deprecated pattern, or intentional removal.