init
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
---
|
||||
source_files:
|
||||
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.TestModification/TestModificationModule.cs
|
||||
generated_at: "2026-04-16T13:42:42.368236+00:00"
|
||||
model: "zai-org/GLM-5-FP8"
|
||||
schema_version: 1
|
||||
sha256: "3f67001eaa6ddf3a"
|
||||
---
|
||||
|
||||
# Documentation: DTS.Viewer.TestModification Module
|
||||
|
||||
## 1. Purpose
|
||||
This module serves as the entry point for the "TestModification" feature within the DTS Viewer application. It is a Prism Module (`IModule`) responsible for registering its associated View (`TestModificationView`) and ViewModel (`TestModificationViewModel`) with the Unity dependency injection container. Additionally, it defines assembly-level metadata attributes that expose the module's name, icon, grouping, and region assignment to the main application shell, enabling the module to be discovered and displayed in the UI.
|
||||
|
||||
## 2. Public Interface
|
||||
|
||||
### Classes
|
||||
|
||||
#### `TestModificationModule`
|
||||
The main module class responsible for dependency injection registration.
|
||||
|
||||
* **`TestModificationModule(IUnityContainer unityContainer)`**
|
||||
* Constructor that accepts a reference to the Unity container via dependency injection.
|
||||
* **`void RegisterTypes(IContainerRegistry containerRegistry)`**
|
||||
* Implements `IModule.RegisterTypes`. Calls the local `Initialize()` method to register views and view models.
|
||||
* **`void OnInitialized(IContainerProvider containerProvider)`**
|
||||
* Implements `IModule.OnInitialized`. Currently contains no implementation logic.
|
||||
* **`void Initialize()`**
|
||||
* Registers `ITestModificationView` to `TestModificationView` and `ITestModificationViewModel` to `TestModificationViewModel` with the Unity container.
|
||||
|
||||
#### `TestModificationModuleNameAttribute`
|
||||
An assembly-level attribute providing the module's name as text.
|
||||
|
||||
* **`string AssemblyName { get; }`**
|
||||
* Returns the string representation of `AssemblyNames.TestModification`.
|
||||
* **`Type GetAttributeType()`**
|
||||
* Returns `typeof(TextAttribute)`.
|
||||
* **`string GetAssemblyName()`**
|
||||
* Returns the `AssemblyName` property value.
|
||||
|
||||
#### `TestModificationModuleImageAttribute`
|
||||
An assembly-level attribute providing image and categorization metadata for the module.
|
||||
|
||||
* **`BitmapImage AssemblyImage { get; }`**
|
||||
* Retrieves the module's image via `AssemblyInfo.GetImage`.
|
||||
* **`string AssemblyName { get; }`**
|
||||
* Returns the string representation of `AssemblyNames.TestModification`.
|
||||
* **`string AssemblyGroup { get; }`**
|
||||
* Returns `eAssemblyGroups.Viewer.ToString()`.
|
||||
* **`eAssemblyRegion AssemblyRegion { get; }`**
|
||||
* Returns `eAssemblyRegion.TestModificationRegion`.
|
||||
* **`BitmapImage GetAssemblyImage()`**
|
||||
* Returns the `AssemblyImage` property.
|
||||
* **`string GetAssemblyName()`**
|
||||
* Returns the `AssemblyName` property.
|
||||
* **`string GetAssemblyGroup()`**
|
||||
* Returns the `AssemblyGroup` property.
|
||||
* **`eAssemblyRegion GetAssemblyRegion()`**
|
||||
* Returns the `AssemblyRegion` property.
|
||||
|
||||
## 3. Invariants
|
||||
* **Module Name:** The module is identified by the string "TestModification" in the `[Module]` attribute.
|
||||
* **Registration Mapping:** `ITestModificationView` is strictly mapped to `TestModificationView`, and `ITestModificationViewModel` is strictly mapped to `TestModificationViewModel`.
|
||||
* **Attribute Usage:** Both custom attributes are decorated with `[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]`, ensuring they are applied only once per assembly.
|
||||
* **Region Assignment:** The module is statically bound to `eAssemblyRegion.TestModificationRegion`.
|
||||
|
||||
## 4. Dependencies
|
||||
|
||||
### Internal Dependencies
|
||||
* **`DTS.Common`**: Used for `AssemblyNames`, `AssemblyInfo`, `eAssemblyGroups`, and `eAssemblyRegion` enums/helpers.
|
||||
* **`DTS.Common.Interface`**: Defines `TextAttribute` and `ImageAttribute`, which the custom attributes inherit from.
|
||||
* **`DTS.Viewer.TestModification` (Local Namespace)**: The module references `TestModificationView`, `TestModificationViewModel`, and their interfaces (`ITestModificationView`, `ITestModificationViewModel`), which are expected to be defined elsewhere in this project/namespace.
|
||||
|
||||
### External Dependencies
|
||||
* **`Prism.Ioc`**: Provides `IContainerProvider` and `IContainerRegistry`.
|
||||
* **`Prism.Modularity`**: Provides the `IModule` interface and `ModuleAttribute`.
|
||||
* **`Unity`**: Provides `IUnityContainer` for specific dependency injection implementation.
|
||||
* **`System.Windows.Media.Imaging`**: Provides `BitmapImage` for module imagery.
|
||||
|
||||
## 5. Gotchas
|
||||
|
||||
* **Mixed Container Abstractions:** The class uses `IContainerRegistry` (Prism abstraction) in `RegisterTypes`, but immediately delegates to the `IUnityContainer` (Unity specific) stored in a field to perform the actual registration. This bypasses Prism's container abstraction, making the module tightly coupled to Unity and potentially ignoring the `containerRegistry` parameter passed to `RegisterTypes`.
|
||||
* **Side Effects in Property Getters:** In `TestModificationModuleImageAttribute`, the `AssemblyImage` property getter performs a file/resource load operation (`AssemblyInfo.GetImage(...)`) and overwrites the private `_img` field every time it is accessed. This is inefficient and violates standard property getter expectations of low cost and idempotency.
|
||||
* **Unused Constructor Parameters:** The constructors for `TestModificationModuleNameAttribute(string s)` and `TestModificationModuleImageAttribute(string s)` accept a string parameter `s` that is never used in the method body.
|
||||
* **Redundant Method:** The `Initialize()` method is public but appears to be legacy code or a specific pattern choice, as `RegisterTypes` is the standard Prism location for type registration. The separation serves no functional purpose given `RegisterTypes` immediately calls it.
|
||||
Reference in New Issue
Block a user