Files
DP44/docs/ai/DataPRO/Modules/Hardware/AddEditHardware.md

59 lines
3.8 KiB
Markdown
Raw Normal View History

2026-04-17 14:55:32 -04:00
---
source_files:
- DataPRO/Modules/Hardware/AddEditHardware/AddEditHardwareModule.cs
generated_at: "2026-04-17T16:30:25.823878+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "10ec7c0a38ddc3b1"
---
# AddEditHardware
### Purpose
This module provides functionality for adding and editing hardware configurations within the DataPRO system. It is a Prism module that registers its view and view model with the Unity dependency injection container, enabling the hardware management UI to be loaded dynamically. The module belongs to the "Prepare" assembly group and targets the "AddEditHardwareRegion" for UI composition.
### Public Interface
**`AddEditHardwareModule`** (class)
- `AddEditHardwareModule(IUnityContainer unityContainer)` - Constructor accepting a Unity container via dependency injection.
- `void Initialize()` - Registers `IAddEditHardwareView` to `AddEditHardwareView` and `IAddEditHardwareViewModel` to `AddEditHardwareViewModel` with the Unity container.
- `void OnInitialized(IContainerProvider containerProvider)` - Empty implementation; no initialization logic executed.
- `void RegisterTypes(IContainerRegistry containerRegistry)` - Calls `Initialize()` to perform type registration.
**`AddEditHardwareModuleNameAttribute`** (class, inherits `TextAttribute`)
- `AddEditHardwareModuleNameAttribute()` / `AddEditHardwareModuleNameAttribute(string s)` - Constructors that set `AssemblyName` to `AssemblyNames.AddEditHardware.ToString()`.
- `string AssemblyName` (property, override) - Returns the assembly name.
- `Type GetAttributeType()` - Returns `typeof(TextAttribute)`.
- `string GetAssemblyName()` - Returns the `AssemblyName` property value.
**`AddEditHardwareModuleImageAttribute`** (class, inherits `ImageAttribute`)
- `AddEditHardwareModuleImageAttribute()` / `AddEditHardwareModuleImageAttribute(string s)` - Constructors that load the assembly image via `AssemblyInfo.GetImage()`.
- `BitmapImage AssemblyImage` (property, override) - Lazy-loads and returns the module's image.
- `string AssemblyName` (property, override) - Returns `AssemblyNames.AddEditHardware.ToString()`.
- `string AssemblyGroup` (property, override) - Returns `eAssemblyGroups.Prepare.ToString()`.
- `eAssemblyRegion AssemblyRegion` (property, override) - Returns `eAssemblyRegion.AddEditHardwareRegion`.
- `BitmapImage GetAssemblyImage()`, `string GetAssemblyName()`, `string GetAssemblyGroup()`, `eAssemblyRegion GetAssemblyRegion()` - Accessor methods for respective properties.
- `Type GetAttributeType()` - Returns `typeof(ImageAttribute)`.
### Invariants
- The module must be instantiated with a non-null `IUnityContainer` reference.
- `Initialize()` must be called (via `RegisterTypes`) before views/view models can be resolved.
- View and ViewModel registrations are transient (not singleton), despite the comment claiming singleton registration.
### Dependencies
**Imports:**
- `DTS.Common` - Provides `TextAttribute`, `ImageAttribute`, `AssemblyNames`, `AssemblyInfo`, `eAssemblyGroups`, `eAssemblyRegion`.
- `DTS.Common.Interface` - Provides base interfaces.
- `DTS.Common.Interface.Hardware.AddEditHardware` - Provides `IAddEditHardwareView`, `IAddEditHardwareViewModel`.
- `Prism.Modularity` - Provides `IModule`, `ModuleAttribute`.
- `Prism.Ioc` - Provides `IContainerProvider`, `IContainerRegistry`.
- `Unity` - Provides `IUnityContainer`.
**Depended on by:** Unknown from source alone (likely shell/bootstrapper and region navigation).
### Gotchas
- The comment in `Initialize()` states "Register View & View-Model... as a singleton," but `RegisterType` registers types as transient by default in Unity. If singleton behavior is required, `RegisterSingleton` or `RegisterInstance` should be used.
- `OnInitialized` is empty but required by `IModule` interface.
- The constructor parameter `string s` in both attribute classes is accepted but never used.
---