103 lines
5.9 KiB
Markdown
103 lines
5.9 KiB
Markdown
|
|
---
|
|||
|
|
source_files:
|
|||
|
|
- DataPRO/Modules/SystemSettings/DBImportExport/DBImportExportModule.cs
|
|||
|
|
generated_at: "2026-04-16T04:39:22.157742+00:00"
|
|||
|
|
model: "Qwen/Qwen3-Coder-Next-FP8"
|
|||
|
|
schema_version: 1
|
|||
|
|
sha256: "148ddc7b73c8539d"
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
# DBImportExport
|
|||
|
|
|
|||
|
|
## Documentation: DBImportExportModule
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
### 1. Purpose
|
|||
|
|
The `DBImportExportModule` is a Prism module responsible for registering the views, view models, and related UI components for database import/export functionality within the application. It integrates with the Unity dependency injection container to expose `IDBImportView`, `IDBExportView`, and `IDBViewModel` as singleton registrations, enabling modular loading of the database import/export UI layer. Additionally, it contributes metadata (via `DBImageAttribute`) used by the main UI to display the module’s icon, name, and group on the main component selection screen.
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
### 2. Public Interface
|
|||
|
|
|
|||
|
|
#### `DBImportExportModule`
|
|||
|
|
- **`DBImportExportModule(IUnityContainer unityContainer)`**
|
|||
|
|
Constructor. Accepts and stores a Unity container reference via dependency injection. Used to register types during initialization.
|
|||
|
|
|
|||
|
|
- **`void Initialize()`**
|
|||
|
|
Registers three types as singletons in the Unity container:
|
|||
|
|
- `IDBImportView → DBImportView`
|
|||
|
|
- `IDBExportView → DBExportView`
|
|||
|
|
- `IDBViewModel → DBViewModel`
|
|||
|
|
This method is called both directly by the constructor’s usage context (via `RegisterTypes`) and potentially by Prism’s module initialization pipeline.
|
|||
|
|
|
|||
|
|
- **`void OnInitialized(IContainerProvider containerProvider)`**
|
|||
|
|
Currently empty; no logic implemented.
|
|||
|
|
|
|||
|
|
- **`void RegisterTypes(IContainerRegistry containerRegistry)`**
|
|||
|
|
Delegates to `Initialize()`, which performs the actual Unity registration. Note: Although the parameter is `IContainerRegistry`, the implementation uses the injected `IUnityContainer`, implying a mismatch between Prism’s `IContainerRegistry` and Unity’s `IUnityContainer`—this may indicate legacy or hybrid DI usage.
|
|||
|
|
|
|||
|
|
#### `DBImageAttribute`
|
|||
|
|
- **`DBImageAttribute()`**
|
|||
|
|
Default constructor; delegates to `DBImageAttribute(string)` with `null`.
|
|||
|
|
|
|||
|
|
- **`DBImageAttribute(string s)`**
|
|||
|
|
Constructor accepting a string (unused in implementation); loads and stores the assembly image via `AssemblyInfo.GetImage(AssemblyNames.DB.ToString())`.
|
|||
|
|
|
|||
|
|
- **`override BitmapImage AssemblyImage { get; }`**
|
|||
|
|
Returns a `BitmapImage` loaded from `AssemblyInfo.GetImage(AssemblyNames.DB.ToString())`. Note: `_img` is a private field reused across calls—potential thread-safety or caching concern.
|
|||
|
|
|
|||
|
|
- **`override string AssemblyName { get; }`**
|
|||
|
|
Returns `"PowerAndBattery"` (from `AssemblyNames.PowerAndBattery.ToString()`), *not* `"DB"` as one might expect given the module name. This is likely an error or legacy artifact.
|
|||
|
|
|
|||
|
|
- **`override string AssemblyGroup { get; }`**
|
|||
|
|
Returns `"Administrative"` (from `eAssemblyGroups.Administrative.ToString()`).
|
|||
|
|
|
|||
|
|
- **`override Type GetAttributeType()`**
|
|||
|
|
Returns `typeof(ImageAttribute)`.
|
|||
|
|
|
|||
|
|
- **`override BitmapImage GetAssemblyImage()`**
|
|||
|
|
Returns the value of `AssemblyImage`.
|
|||
|
|
|
|||
|
|
- **`override string GetAssemblyName()`**
|
|||
|
|
Returns the value of `AssemblyName`.
|
|||
|
|
|
|||
|
|
- **`override eAssemblyRegion GetAssemblyRegion()`**
|
|||
|
|
Throws `NotImplementedException`.
|
|||
|
|
|
|||
|
|
- **`override eAssemblyRegion AssemblyRegion { get; }`**
|
|||
|
|
Throws `NotImplementedException`.
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
### 3. Invariants
|
|||
|
|
- `DBImportExportModule` must be initialized *after* the Unity container is available (via DI), and before views/view models are resolved.
|
|||
|
|
- The `AssemblyName` property *always* returns `"PowerAndBattery"` regardless of the actual module name (`"DBImportExportModule"`), indicating a likely bug or misconfiguration.
|
|||
|
|
- `AssemblyRegion` and `GetAssemblyRegion()` are unimplemented and will throw at runtime if invoked.
|
|||
|
|
- `AssemblyImage` relies on `AssemblyInfo.GetImage(AssemblyNames.DB.ToString())`, so correctness depends on `AssemblyNames.DB` being defined and `AssemblyInfo.GetImage(...)` returning a valid `BitmapImage`.
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
### 4. Dependencies
|
|||
|
|
|
|||
|
|
#### Dependencies *of* this module:
|
|||
|
|
- **Unity (`IUnityContainer`, `IContainerRegistry`)** — for type registration.
|
|||
|
|
- **Prism (`IModule`, `IContainerProvider`, `IContainerRegistry`)** — for module lifecycle integration.
|
|||
|
|
- **DTS.Common (`AssemblyInfo`, `AssemblyNames`, `eAssemblyGroups`, `ImageAttribute`)** — for assembly metadata and image retrieval.
|
|||
|
|
- **System.Windows.Media.Imaging (`BitmapImage`)** — for image representation.
|
|||
|
|
|
|||
|
|
#### Dependencies *on* this module:
|
|||
|
|
- Any module or UI component that consumes `IDBImportView`, `IDBExportView`, or `IDBViewModel` (e.g., shell views, navigation services).
|
|||
|
|
- The main application shell likely uses `DBImageAttribute` (via reflection over assemblies) to populate the component selection UI.
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
### 5. Gotchas
|
|||
|
|
- **Critical naming mismatch**: `AssemblyName` returns `"PowerAndBattery"` instead of `"DB"` or `"DBImportExport"`. This will cause incorrect labeling in the UI.
|
|||
|
|
- **Unimplemented methods**: `AssemblyRegion`, `GetAssemblyRegion()` throw `NotImplementedException`. If invoked (e.g., by UI code expecting full metadata), the app will crash.
|
|||
|
|
- **Field reuse in `AssemblyImage`**: `_img` is reused across property accesses without null-check or thread-safety. If `AssemblyInfo.GetImage(...)` fails or returns null, subsequent accesses may return stale or invalid data.
|
|||
|
|
- **`RegisterTypes` uses `IUnityContainer` despite receiving `IContainerRegistry`**: This suggests a mismatch between Prism’s DI abstraction and Unity’s concrete container, possibly indicating legacy code or improper migration.
|
|||
|
|
- **`OnInitialized` is empty**: If initialization logic was intended here (e.g., post-registration wiring), it is missing.
|
|||
|
|
- **No validation or error handling**: If `AssemblyNames.DB` is undefined or `AssemblyInfo.GetImage(...)` fails, the attribute constructor or property getter will throw silently during assembly load or UI rendering.
|
|||
|
|
|
|||
|
|
None identified beyond those above.
|