90 lines
6.2 KiB
Markdown
90 lines
6.2 KiB
Markdown
---
|
|
source_files:
|
|
- DTS Viewer/DTS.Viewer.Reports/DTS.Viewer.PSDReportSettings/PSDReportSettingsModule.cs
|
|
generated_at: "2026-04-16T13:37:20.992121+00:00"
|
|
model: "zai-org/GLM-5-FP8"
|
|
schema_version: 1
|
|
sha256: "272bb780c04413d3"
|
|
---
|
|
|
|
# Documentation: PSDReportSettingsModule
|
|
|
|
## 1. Purpose
|
|
This module serves as the entry point for the "PSD Report Settings" feature within the DTS Viewer application. It is a Prism Module (`PSDReportSettingsModule`) responsible for registering its specific View, ViewModel, and Model implementations with the Unity dependency injection container. Additionally, it defines assembly-level attributes to expose metadata (name, image, group, and region) to the main application shell, enabling the module to be discovered and displayed as an available component.
|
|
|
|
## 2. Public Interface
|
|
|
|
### Class: `PSDReportSettingsModule`
|
|
Implements `Prism.Modularity.IModule`.
|
|
|
|
* **Constructor**: `PSDReportSettingsModule(IUnityContainer unityContainer)`
|
|
* Accepts an `IUnityContainer` instance via constructor injection and stores it in a readonly field.
|
|
* **Method**: `void Initialize()`
|
|
* Registers three type mappings in the Unity container:
|
|
* `IPSDReportSettingsViewModel` mapped to `PSDReportSettingsViewModel`.
|
|
* `IPSDReportSettingsModel` mapped to `PSDReportSettingsModel`.
|
|
* `IPSDReportSettingsView` mapped to `PSDReportSettingsView`.
|
|
* **Method**: `void RegisterTypes(IContainerRegistry containerRegistry)`
|
|
* Implements `IModule.RegisterTypes`. It invokes the `Initialize()` method.
|
|
* **Method**: `void OnInitialized(IContainerProvider containerProvider)`
|
|
* Implements `IModule.OnInitialized`. This method is currently empty.
|
|
|
|
### Class: `PSDReportSettingsModuleNameAttribute`
|
|
Inherits from `TextAttribute`.
|
|
|
|
* **Constructor**: `PSDReportSettingsModuleNameAttribute()` / `PSDReportSettingsModuleNameAttribute(string s)`
|
|
* Hardcodes the `AssemblyName` property to `AssemblyNames.PSDReportSettings.ToString()`. The string argument `s` in the overloaded constructor is ignored.
|
|
* **Property**: `string AssemblyName { get; }`
|
|
* Returns the hardcoded assembly name string.
|
|
* **Method**: `Type GetAttributeType()`
|
|
* Returns `typeof(TextAttribute)`.
|
|
* **Method**: `string GetAssemblyName()`
|
|
* Returns the value of the `AssemblyName` property.
|
|
|
|
### Class: `PSDReportSettingsModuleImageAttribute`
|
|
Inherits from `ImageAttribute`.
|
|
|
|
* **Constructor**: `PSDReportSettingsModuleImageAttribute()` / `PSDReportSettingsModuleImageAttribute(string s)`
|
|
* Initializes a private `BitmapImage` field (`_img`) by calling `AssemblyInfo.GetImage`. The string argument `s` is ignored.
|
|
* **Property**: `BitmapImage AssemblyImage { get; }`
|
|
* Gets the image by calling `AssemblyInfo.GetImage` with the `AssemblyNames.PSDReportSettings` enum value.
|
|
* **Property**: `string AssemblyName { get; }`
|
|
* Returns `AssemblyNames.PSDReportSettings.ToString()`.
|
|
* **Property**: `string AssemblyGroup { get; }`
|
|
* Returns `eAssemblyGroups.Viewer.ToString()`.
|
|
* **Property**: `eAssemblyRegion AssemblyRegion { get; }`
|
|
* Returns `eAssemblyRegion.PSDReportSettingsRegion`.
|
|
* **Methods**:
|
|
* `Type GetAttributeType()`: Returns `typeof(ImageAttribute)`.
|
|
* `BitmapImage GetAssemblyImage()`: Returns `AssemblyImage`.
|
|
* `string GetAssemblyName()`: Returns `AssemblyName`.
|
|
* `string GetAssemblyGroup()`: Returns `AssemblyGroup`.
|
|
* `eAssemblyRegion GetAssemblyRegion()`: Returns `AssemblyRegion`.
|
|
|
|
## 3. Invariants
|
|
* **Module Name**: The Prism module is identified by the string `"PSDReportSettings"` via the `[Module]` attribute.
|
|
* **Assembly Attributes**: The assembly is decorated with both `PSDReportSettingsModuleNameAttribute` and `PSDReportSettingsModuleImageAttribute` with `AllowMultiple = false`.
|
|
* **Registration Mapping**: The `Initialize` method guarantees that `IPSDReportSettingsViewModel`, `IPSDReportSettingsModel`, and `IPSDReportSettingsView` are registered with the container upon module initialization.
|
|
* **Region Assignment**: This module is statically bound to the region `eAssemblyRegion.PSDReportSettingsRegion`.
|
|
|
|
## 4. Dependencies
|
|
|
|
### Internal Dependencies
|
|
* **DTS.Common**: Referenced for `AssemblyNames`, `AssemblyInfo`, `eAssemblyGroups`, and `eAssemblyRegion`.
|
|
* **DTS.Common.Interface**: Referenced for base classes `TextAttribute` and `ImageAttribute`.
|
|
* **Local Types**: The module depends on the existence of `PSDReportSettingsViewModel`, `PSDReportSettingsModel`, and `PSDReportSettingsView` (and their corresponding interfaces), though these types are not defined in the provided source snippet.
|
|
|
|
### External Dependencies
|
|
* **Prism.Ioc**: For `IContainerProvider` and `IContainerRegistry`.
|
|
* **Prism.Modularity**: For `IModule` and `ModuleAttribute`.
|
|
* **Unity**: For `IUnityContainer` (used for specific registration logic).
|
|
* **System.Windows.Media.Imaging**: For `BitmapImage`.
|
|
|
|
### Consumers
|
|
* The DTS Viewer main application shell (inferred from the module structure and `eAssemblyGroups.Viewer` group assignment).
|
|
|
|
## 5. Gotchas
|
|
* **Mixed Container Abstractions**: The module implements `IModule`, which provides a `RegisterTypes(IContainerRegistry containerRegistry)` method intended for container-agnostic registration. However, the implementation ignores the `containerRegistry` argument and instead uses the injected `IUnityContainer` instance via the `Initialize()` method. This ties the module specifically to Unity, bypassing Prism's container abstraction layer.
|
|
* **Redundant Constructor Arguments**: Both attribute classes possess constructors accepting a `string s` argument. This argument is unused in both constructors, suggesting legacy code or a requirement of the base attribute constructor signature that was implemented but not utilized.
|
|
* **Property Side Effects**: In `PSDReportSettingsModuleImageAttribute`, the getter for `AssemblyImage` re-executes `AssemblyInfo.GetImage(...)` and reassigns the private field `_img` every time it is accessed, rather than returning the cached value.
|
|
* **Empty OnInitialized**: The `OnInitialized` method is explicitly empty. If the View needs to be loaded into a region automatically upon startup, that logic is absent from this module class. |