--- source_files: - DataPRO/Modules/Hardware/HardwareList/HardwareListModule.cs generated_at: "2026-04-16T04:36:26.091510+00:00" model: "Qwen/Qwen3-Coder-Next-FP8" schema_version: 1 sha256: "253455657d30760d" --- # HardwareList ## Documentation: HardwareListModule --- ### 1. Purpose The `HardwareListModule` is a Prism-based modular component responsible for registering core views and view models related to hardware inventory management within the application’s UI framework. It integrates with Unity as the dependency injection container to expose singleton instances of interfaces such as `IHardwareListView`, `ISLICE6TreeView`, and `IHardwareListViewModel`, enabling modular UI composition and decoupled view-model binding. The module also contributes metadata (name, image, group, region) to the host application’s module discovery and presentation system via assembly-level attributes. --- ### 2. Public Interface #### `HardwareListModule` class - **Namespace**: `HardwareList` - **Inherits**: `IModule` (Prism) - **Constructor**: ```csharp public HardwareListModule(IUnityContainer unityContainer) ``` Injects the Unity container for later type registration. - **`Initialize()`**: ```csharp public void Initialize() ``` Registers the following view and view model types as *transient* (note: despite the comment, Unity’s `RegisterType()` defaults to transient unless `ContainerControlledLifetimeManager` is specified): - `IHardwareListView` → `HardwareListView` - `ISLICE6TreeView` → `SLICE6TreeView` - `IHardwareListOverdueView` → `HardwareListOverdueView` - `IHardwareListSelectView` → `HardwareListSelectView` - `IHardwareListViewModel` → `HardwareListViewModel` - `IHardwareListReplaceView` → `HardwareListReplaceView` - **`OnInitialized(IContainerProvider containerProvider)`**: ```csharp public void OnInitialized(IContainerProvider containerProvider) ``` Empty implementation; no post-initialization logic. - **`RegisterTypes(IContainerRegistry containerRegistry)`**: ```csharp public void RegisterTypes(IContainerRegistry containerRegistry) ``` Delegates to `Initialize()`, which uses the injected `IUnityContainer` (not `containerRegistry`). *Note: This is likely a bug or legacy pattern—`containerRegistry` is unused.* #### Assembly-level attributes - **`HardwareListModuleNameAttribute`** - **Usage**: `[assembly: HardwareListModuleName]` - **Purpose**: Exposes the module’s assembly name (`AssemblyNames.HardwareList.ToString()`) for runtime identification. - **Key properties**: - `AssemblyName`: Returns `"HardwareList"` (via `AssemblyNames.HardwareList`). - `GetAttributeType()`: Returns `typeof(TextAttribute)`. - **`HardwareListModuleImageAttribute`** - **Usage**: `[assembly: HardwareListModuleImageAttribute]` - **Purpose**: Supplies UI metadata (image, group, region) for display on the main screen’s module summary. - **Key properties**: - `AssemblyImage`: Loads image via `AssemblyInfo.GetImage("HardwareList")`. - `AssemblyGroup`: Returns `"Prepare"` (via `eAssemblyGroups.Prepare`). - `AssemblyRegion`: Returns `eAssemblyRegion.HardwareListRegion`. - `AssemblyName`: Returns `"HardwareList"`. --- ### 3. Invariants - **Module registration order**: Views/view models are registered during `Initialize()`; no guarantees about registration order relative to other modules (depends on Prism’s module loading sequence). - **Lifetime management**: All registrations use Unity’s default transient lifetime (despite the comment claiming "singleton"). No singleton behavior is enforced. - **Attribute constraints**: - `HardwareListModuleNameAttribute` and `HardwareListModuleImageAttribute` are assembly-level, non-repeatable (`AllowMultiple = false`). - `AssemblyRegion` must be `eAssemblyRegion.HardwareListRegion`. - `AssemblyGroup` must be `eAssemblyGroups.Prepare`. --- ### 4. Dependencies #### Dependencies *of* this module: - **Prism.Modularity**: For `IModule` interface. - **Unity**: For `IUnityContainer` and `IContainerRegistry` (though `RegisterTypes` uses Unity, not the Prism container registry). - **DTS.Common** and **DTS.Common.Interface**: Specifically: - `AssemblyNames.HardwareList` (enum) - `AssemblyInfo.GetImage()` - `eAssemblyGroups` and `eAssemblyRegion` enums - **System.Windows.Media.Imaging**: For `BitmapImage` in `HardwareListModuleImageAttribute`. #### Dependencies *on* this module: - Host application likely depends on `HardwareListModule` to resolve hardware-related views (e.g., `IHardwareListView`) via DI. - Other modules may depend on interfaces like `ISLICE6TreeView` or `IHardwareListViewModel` for composition. --- ### 5. Gotchas - **`RegisterTypes` ignores `containerRegistry`**: The `RegisterTypes` method calls `Initialize()`, which uses the pre-injected `_unityContainer`. This contradicts Prism’s recommended pattern (where `RegisterTypes` should use `containerRegistry`) and may cause issues if the module is loaded in a Prism container that does not share Unity’s container instance. - **Misleading comment**: The `Initialize()` method’s comment claims registrations are "singleton", but Unity’s `RegisterType()` without a lifetime manager is transient. - **Attribute duplication**: Both `HardwareListModuleNameAttribute` and `HardwareListModuleImageAttribute` define `AssemblyName` identically, but only `HardwareListModuleImageAttribute` provides UI-relevant metadata. - **No error handling**: `AssemblyInfo.GetImage()` may fail (e.g., missing image resource), but no fallback or logging is present in the attributes. - **Unused `OnInitialized`**: The `OnInitialized` method is empty and unused—potential dead code. - **Namespace `HardwareList`**: The namespace matches the module name, which may cause confusion with the `HardwareList` folder path or other similarly named components. None identified from source alone beyond the above.