107 lines
5.6 KiB
Markdown
107 lines
5.6 KiB
Markdown
---
|
||
source_files:
|
||
- DataPRO/Modules/Reports/PedestrianAndHeadReports/PedestrianAndHeadReportsModule.cs
|
||
generated_at: "2026-04-16T04:54:47.725331+00:00"
|
||
model: "Qwen/Qwen3-Coder-Next-FP8"
|
||
schema_version: 1
|
||
sha256: "ccf0154da364c5ff"
|
||
---
|
||
|
||
# PedestrianAndHeadReports
|
||
|
||
## Documentation: `PedestrianAndHeadReportsModule`
|
||
|
||
---
|
||
|
||
### 1. **Purpose**
|
||
|
||
This module registers UI components (views and view models) for two report types—**Head Reports** and **TRL Reports**—within the Prism-based modular application architecture. It serves as the initialization point for integrating these report-related views into the application’s dependency injection container (Unity), enabling view resolution and composition at runtime. The module also contributes metadata (via `PedestrianAndHeadReportsImageAttribute`) to identify the module on the main screen, including its display name, group, and icon.
|
||
|
||
---
|
||
|
||
### 2. **Public Interface**
|
||
|
||
#### `PedestrianAndHeadReportsModule` class
|
||
|
||
- **`PedestrianAndHeadReportsModule(IUnityContainer unityContainer)`**
|
||
Constructor. Accepts a Unity container via dependency injection and stores it for later use in type registration.
|
||
|
||
- **`void Initialize()`**
|
||
Implements `IModule.Initialize()`. Registers the following view and view model types as *singleton* mappings in the Unity container:
|
||
- `IHeadReportInputView` → `HeadReportInputView`
|
||
- `IHeadReportOutputView` → `HeadReportOutputView`
|
||
- `IHeadReportViewModel` → `HeadReportViewModel`
|
||
- `ITRLReportInputView` → `TRLReportInputView`
|
||
- `ITRLReportOutputView` → `TRLReportOutputView`
|
||
- `ITRLReportViewModel` → `TRLReportViewModel`
|
||
These registrations allow the application to resolve and instantiate these components via interface-based injection.
|
||
|
||
#### `PedestrianAndHeadReportsImageAttribute` class
|
||
|
||
- **`PedestrianAndHeadReportsImageAttribute()`**
|
||
Default constructor; delegates to the parameterized constructor with `null`.
|
||
|
||
- **`PedestrianAndHeadReportsImageAttribute(string s)`**
|
||
Constructor accepting a string argument (currently unused in implementation).
|
||
|
||
- **`override BitmapImage AssemblyImage { get; }`**
|
||
Returns a `BitmapImage` loaded via `AssemblyInfo.GetImage(AssemblyNames.DB.ToString())`.
|
||
|
||
- **`override string AssemblyName { get; }`**
|
||
Returns `"PowerAndBattery"` (from `AssemblyNames.PowerAndBattery.ToString()`), *not* `"PedestrianAndHeadReports"`—note this appears inconsistent with module name.
|
||
|
||
- **`override string AssemblyGroup { get; }`**
|
||
Returns `"Administrative"` (from `eAssemblyGroups.Administrative.ToString()`).
|
||
|
||
- **`override BitmapImage GetAssemblyImage()`**
|
||
Delegates to `AssemblyImage`.
|
||
|
||
- **`override string GetAssemblyName()`**
|
||
Delegates to `AssemblyName`.
|
||
|
||
- **`override string GetAssemblyGroup()`**
|
||
Delegates to `AssemblyGroup`.
|
||
|
||
- **`override eAssemblyRegion GetAssemblyRegion()`**
|
||
Throws `NotImplementedException`.
|
||
|
||
- **`override eAssemblyRegion AssemblyRegion => throw new NotImplementedException();`**
|
||
Property version also throws `NotImplementedException`.
|
||
|
||
> ⚠️ **Note**: The `AssemblyName` and `AssemblyImage` properties use values from *other* assemblies (`PowerAndBattery`, `DB`), which may be intentional (e.g., shared branding) or a bug. The source does not clarify intent.
|
||
|
||
---
|
||
|
||
### 3. **Invariants**
|
||
|
||
- The `IUnityContainer` instance passed to the constructor must be non-null and fully initialized before `Initialize()` is called.
|
||
- All registered view/view-model types (`HeadReportInputView`, `HeadReportOutputView`, etc.) must be concrete types implementing their respective interfaces.
|
||
- The `AssemblyImage` and `AssemblyName` properties *always* return the same values (hardcoded via `AssemblyInfo.GetImage(...)` and `AssemblyNames.DB/PowerAndBattery`), regardless of runtime state.
|
||
- `GetAssemblyRegion()` and `AssemblyRegion` are **unimplemented** and will always throw `NotImplementedException` if invoked.
|
||
|
||
---
|
||
|
||
### 4. **Dependencies**
|
||
|
||
#### Dependencies *of* this module:
|
||
- `DTS.Common` (specifically `AssemblyInfo`, `AssemblyNames`, `eAssemblyGroups`)
|
||
- `Microsoft.Practices.Prism.Modularity` (`IModule`)
|
||
- `Microsoft.Practices.Unity` (`IUnityContainer`)
|
||
- `System.ComponentModel.Composition` (`Export`)
|
||
- `System.Windows.Media.Imaging` (`BitmapImage`)
|
||
|
||
#### Dependencies *on* this module:
|
||
- The main application shell or module catalog must load this module to enable the registered views.
|
||
- Other modules or services that resolve `IHeadReportInputView`, `ITRLReportViewModel`, etc., rely on this module’s `Initialize()` having been called first.
|
||
|
||
---
|
||
|
||
### 5. **Gotchas**
|
||
|
||
- **Inconsistent naming**: `AssemblyName` returns `"PowerAndBattery"` instead of `"PedestrianAndHeadReports"`. This may cause incorrect labeling in UI or module discovery logic.
|
||
- **Unimplemented region properties**: `GetAssemblyRegion()` and `AssemblyRegion` throw exceptions—any UI or logic expecting region metadata will crash if invoked.
|
||
- **Unused constructor parameter**: The `string s` parameter in `PedestrianAndHeadReportsImageAttribute(string s)` is accepted but never used.
|
||
- **Hardcoded assembly references**: `AssemblyNames.DB` and `AssemblyNames.PowerAndBattery` are used directly; if these enums change or are misnamed, image/name resolution will fail silently or throw.
|
||
- **No validation in `Initialize()`**: No checks ensure the container is valid or registrations succeed; failures may surface later as resolution errors.
|
||
- **Singleton registration assumed**: Unity’s default `RegisterType` behavior is transient, but the comment states *singleton*. Verify actual lifetime behavior matches intent (source does not specify `ContainerControlledLifetimeManager` explicitly).
|
||
→ *If singleton behavior is required, the current code is incorrect.* |