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

78 lines
5.6 KiB
Markdown

---
source_files:
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.TestModification/TestModificationModule.cs
generated_at: "2026-04-16T11:04:46.076317+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "3f67001eaa6ddf3a"
---
# Documentation: TestModificationModule
## 1. Purpose
This module serves as the entry point for the "TestModification" feature within the DTS Viewer application. It implements the `IModule` interface from the Prism framework to handle dependency injection registration for the feature's View and ViewModel. Additionally, it defines assembly-level attributes to provide metadata (name, icon, region, and group) used by the main application shell to identify and display the module to the end-user.
## 2. Public Interface
### Class: `TestModificationModule`
The main module class responsible for registering application components.
* **Constructor**: `TestModificationModule(IUnityContainer unityContainer)`
* Accepts an `IUnityContainer` instance via dependency injection and stores it in a private readonly field.
* **Method**: `void RegisterTypes(IContainerRegistry containerRegistry)`
* Implements `IModule.RegisterTypes`. Invokes the private `Initialize()` method to register types with the Unity container.
* **Method**: `void OnInitialized(IContainerProvider containerProvider)`
* Implements `IModule.OnInitialized`. Currently contains no implementation logic.
### Class: `TestModificationModuleNameAttribute`
An assembly-level attribute providing the module's name metadata.
* **Constructor**: `TestModificationModuleNameAttribute()` / `TestModificationModuleNameAttribute(string s)`
* Initializes the `AssemblyName` property using the `AssemblyNames.TestModification` enum value.
* **Property**: `override string AssemblyName`
* Returns the string representation of `AssemblyNames.TestModification`.
* **Method**: `override Type GetAttributeType()`
* Returns `typeof(TextAttribute)`.
* **Method**: `override string GetAssemblyName()`
* Returns the `AssemblyName` property value.
### Class: `TestModificationModuleImageAttribute`
An assembly-level attribute providing image and grouping metadata for the module.
* **Constructor**: `TestModificationModuleImageAttribute()` / `TestModificationModuleImageAttribute(string s)`
* Initializes the assembly image by calling `AssemblyInfo.GetImage`.
* **Property**: `override BitmapImage AssemblyImage`
* Retrieves and caches a `BitmapImage` associated with `AssemblyNames.TestModification`.
* **Property**: `override string AssemblyName`
* Returns the string representation of `AssemblyNames.TestModification`.
* **Property**: `override string AssemblyGroup`
* Returns `eAssemblyGroups.Viewer.ToString()`.
* **Property**: `override eAssemblyRegion AssemblyRegion`
* Returns `eAssemblyRegion.TestModificationRegion`.
* **Methods**: `GetAssemblyImage()`, `GetAssemblyName()`, `GetAssemblyGroup()`, `GetAssemblyRegion()`
* Accessors returning the values of their respective properties defined above.
## 3. Invariants
* **Module Name**: The module is identified by the string "TestModification" via the `[Module]` attribute.
* **Assembly Region**: The module is strictly associated with `eAssemblyRegion.TestModificationRegion`.
* **Assembly Group**: The module belongs to the `eAssemblyGroups.Viewer` group.
* **Attribute Usage**: Both custom attributes are decorated with `[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]`, ensuring only one instance of each exists per assembly.
* **Registration**: The `ITestModificationView` interface is always mapped to the `TestModificationView` concrete type, and `ITestModificationViewModel` is mapped to `TestModificationViewModel`.
## 4. Dependencies
### Internal Dependencies
* **DTS.Common**: Used for `TextAttribute`, `ImageAttribute`, `AssemblyNames`, `AssemblyInfo`, `eAssemblyGroups`, and `eAssemblyRegion`.
* **DTS.Common.Interface**: Used for `ITestModificationView` and `ITestModificationViewModel` interfaces.
* **Concrete Types**: References `TestModificationView` and `TestModificationViewModel` (source files not provided, assumed to exist within the namespace).
### External Dependencies
* **Prism.Ioc**: Provides `IContainerProvider` and `IContainerRegistry`.
* **Prism.Modularity**: Provides `IModule` and `ModuleAttribute`.
* **Unity**: Provides `IUnityContainer` for dependency injection.
* **System.Windows.Media.Imaging**: Provides `BitmapImage` for image handling.
## 5. Gotchas
* **Comment/Code Mismatch**: The comment in `Initialize()` states: "Register View & View-Model ... as a singleton." However, the code uses `_unityContainer.RegisterType<...>()`. In Unity, `RegisterType` registers a transient mapping (new instance per resolve) by default, not a singleton. If a singleton is intended, `RegisterSingleton` or `RegisterInstance` should be used.
* **Mixed Container Usage**: The module receives an `IContainerProvider` in `OnInitialized` and an `IContainerRegistry` in `RegisterTypes` (standard Prism), but the constructor specifically requests the concrete `IUnityContainer`. The `Initialize` method uses this concrete `_unityContainer` reference to register types, bypassing the abstraction provided by `IContainerRegistry`. This ties the module specifically to the Unity container, reducing portability to other DI containers supported by Prism.
* **Unused Parameters**: The constructors for `TestModificationModuleNameAttribute` and `TestModificationModuleImageAttribute` accept a `string s` parameter that is effectively ignored (the logic inside relies on `AssemblyNames.TestModification` instead of the passed string).