Files
DP44/enriched-qwen3-coder-next/DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.ViewerSettings.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.Modules/DTS.Viewer.ViewerSettings/ViewerSettingsModule.cs
2026-04-16T13:43:31.988830+00:00 zai-org/GLM-5-FP8 1 9f0f5c6b474b7ca8

Documentation: DTS.Viewer.ViewerSettings Module

1. Purpose

This module serves as the entry point for the "Viewer Settings" feature within the DTS application. It is responsible for self-registering its View and ViewModel components with the Unity dependency injection container and providing assembly metadata (name, image, grouping, and region) to the broader application infrastructure. It follows the Prism modular architecture to encapsulate viewer configuration logic.

2. Public Interface

ViewerSettingsModule

The main module class implementing Prism.Modularity.IModule.

  • ViewerSettingsModule(IUnityContainer unityContainer)
    • Constructor that accepts an IUnityContainer instance via dependency injection and stores it in a private readonly field _unityContainer.
  • void RegisterTypes(IContainerRegistry containerRegistry)
    • Implements IModule.RegisterTypes. Calls the private Initialize() method to perform type registrations.
  • void OnInitialized(IContainerProvider containerProvider)
    • Implements IModule.OnInitialized. Currently contains no implementation logic.

ViewerSettingsModuleNameAttribute

An assembly-level attribute extending TextAttribute used to define the module's name.

  • ViewerSettingsModuleNameAttribute()
    • Default constructor.
  • ViewerSettingsModuleNameAttribute(string s)
    • Overloaded constructor accepting a string argument (which is unused in the body).
  • string AssemblyName { get; }
    • Returns the string representation of AssemblyNames.ViewerSettings.
  • Type GetAttributeType()
    • Returns typeof(TextAttribute).
  • string GetAssemblyName()
    • Returns the AssemblyName property value.

ViewerSettingsModuleImageAttribute

An assembly-level attribute extending ImageAttribute used to provide visual metadata for the module.

  • ViewerSettingsModuleImageAttribute()
    • Default constructor.
  • ViewerSettingsModuleImageAttribute(string s)
    • Overloaded constructor accepting a string argument (unused in the body).
  • BitmapImage AssemblyImage { get; }
    • Retrieves an image using AssemblyInfo.GetImage(AssemblyNames.ViewerSettings.ToString()).
  • string AssemblyName { get; }
    • Returns the string representation of AssemblyNames.ViewerSettings.
  • string AssemblyGroup { get; }
    • Returns eAssemblyGroups.Viewer.ToString().
  • eAssemblyRegion AssemblyRegion { get; }
    • Returns eAssemblyRegion.ViewerSettingsRegion.
  • Methods: GetAttributeType(), GetAssemblyImage(), GetAssemblyName(), GetAssemblyGroup(), GetAssemblyRegion() return the values of their respective properties.

3. Invariants

  • Registration Mapping: The module registers the interface IViewerSettingsView to the concrete type ViewerSettingsView and IViewerSettingsViewModel to ViewerSettingsViewModel.
  • Attribute Usage: Both ViewerSettingsModuleNameAttribute and ViewerSettingsModuleImageAttribute are decorated with AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false), ensuring they appear only once per assembly.
  • Naming Consistency: The AssemblyName property in both attribute classes is hardcoded to the AssemblyNames.ViewerSettings enum value.
  • Region Assignment: The module is explicitly assigned to the eAssemblyRegion.ViewerSettingsRegion.

4. Dependencies

Internal Dependencies (Inferred from usage)

  • DTS.Common: Used for AssemblyNames, eAssemblyGroups, eAssemblyRegion, and AssemblyInfo.
  • DTS.Common.Interface: Defines TextAttribute, ImageAttribute, IViewerSettingsView, and IViewerSettingsViewModel.
  • ViewerSettingsView / ViewerSettingsViewModel: Concrete types referenced in Initialize() (source not provided, assumed to exist in this or a related assembly).

External Libraries

  • Prism.Ioc: Provides IContainerProvider, IContainerRegistry.
  • Prism.Modularity: Provides IModule.
  • Unity: Provides IUnityContainer (Microsoft.Practices.Unity).
  • System.Windows.Media.Imaging: Provides BitmapImage.

5. Gotchas

  • Mixed Container Abstractions: The RegisterTypes method receives an IContainerRegistry (Prism abstraction) but ignores it. Instead, it calls Initialize(), which uses the injected IUnityContainer (concrete Unity implementation) directly. This bypasses Prism's container abstraction, which could cause issues if the container implementation is swapped or if the registry context is required for specific Prism features.
  • Commented-Out Registration: The line _unityContainer.RegisterType<IViewerSettingsModel, ViewerSettingsModel>(); is commented out. It is unclear if the Model is intentionally excluded, obsolete, or if this is incomplete work.
  • Unused Constructor Parameters: Both attribute classes (ViewerSettingsModuleNameAttribute and ViewerSettingsModuleImageAttribute) define constructors that accept a string s parameter but never use it. This suggests legacy refactoring or a design pattern where the parameter is ignored.
  • Property Side-Effects: In ViewerSettingsModuleImageAttribute, the AssemblyImage property getter modifies the private field _img (lazy initialization pattern inside a getter). This is a side-effect that can be confusing during debugging.