--- source_files: - DataPRO/Modules/Groups/GroupImport/GroupImportModule.cs generated_at: "2026-04-16T04:45:20.865762+00:00" model: "Qwen/Qwen3-Coder-Next-FP8" schema_version: 1 sha256: "99bf820620f80499" --- # GroupImport ## Documentation: `GroupImportModule` --- ### 1. **Purpose** The `GroupImportModule` is a Prism module responsible for registering the views and view models required for the *Group Import* functionality within the application’s UI. It integrates with the Unity dependency injection container to expose the necessary components (`IGroupImportImportView`, `IGroupImportOptionsView`, `IGroupImportPreviewView`, and `IGroupImportViewModel`) as singleton registrations, enabling modular, testable, and loosely coupled UI construction. Additionally, it provides assembly-level metadata via the `GroupImageAttribute`, which is used by the main UI to display the module’s name, group (e.g., “Prepare”), and associated icon. --- ### 2. **Public Interface** #### `GroupImportModule` class - **`GroupImportModule(IUnityContainer unityContainer)`** Constructor. Accepts a Unity container via dependency injection and stores it for later use in type registration. - **`void Initialize()`** Registers the following types as singletons in the Unity container: - `IGroupImportImportView` → `GroupImportImportView` - `IGroupImportOptionsView` → `GroupImportOptionsView` - `IGroupImportPreviewView` → `GroupImportPreviewView` - `IGroupImportViewModel` → `GroupImportViewModel` This method is called by both `Prism.Modularity.IModule.Initialize()` and `RegisterTypes()`. - **`void OnInitialized(IContainerProvider containerProvider)`** Currently empty; no initialization logic beyond type registration is performed. - **`void RegisterTypes(IContainerRegistry containerRegistry)`** Delegates to `Initialize()`. (Note: Despite accepting `IContainerRegistry`, it uses the injected `IUnityContainer` internally.) #### `GroupImageAttribute` class - **`GroupImageAttribute()`** Default constructor; initializes image via `AssemblyInfo.GetImage(AssemblyNames.GroupImport.ToString())`. - **`GroupImageAttribute(string s)`** Constructor accepting a string argument (unused); initializes image identically to the default constructor. - **`override BitmapImage AssemblyImage`** Returns a `BitmapImage` loaded via `AssemblyInfo.GetImage(AssemblyNames.GroupImport.ToString())`. - **`override string AssemblyName`** Returns `"GroupImport"` (from `AssemblyNames.GroupImport.ToString()`). - **`override string AssemblyGroup`** Returns `"Prepare"` (from `eAssemblyGroups.Prepare.ToString()`). - **`override eAssemblyRegion AssemblyRegion`** Throws `NotImplementedException`. *Not implemented.* - **`override Type GetAttributeType()`** Returns `typeof(ImageAttribute)`. - **`override BitmapImage GetAssemblyImage()`** Returns the value of `AssemblyImage`. - **`override string GetAssemblyName()`** Returns the value of `AssemblyName`. - **`override string GetAssemblyGroup()`** Returns the value of `AssemblyGroup`. - **`override eAssemblyRegion GetAssemblyRegion()`** Throws `NotImplementedException`. *Not implemented.* --- ### 3. **Invariants** - The `GroupImportModule` must be initialized *after* the Unity container is available (via DI), and before any views/view models are resolved. - All registered types (`IGroupImport*View`, `IGroupImportViewModel`) are registered as *singletons* (default Unity lifetime). - `GroupImageAttribute` is applied at the **assembly level** (via `[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]`), and only one instance per assembly is allowed. - `AssemblyImage`, `AssemblyName`, and `AssemblyGroup` are computed *at runtime* using static methods (`AssemblyInfo.GetImage`, `AssemblyNames.GroupImport`, `eAssemblyGroups.Prepare`). Their values depend on external definitions in `DTS.Common` and must be consistent. - `AssemblyRegion` and `GetAssemblyRegion()` are **not implemented** and will throw `NotImplementedException` if invoked. --- ### 4. **Dependencies** #### **Depends on** - `DTS.Common` (specifically `AssemblyInfo`, `AssemblyNames`, `eAssemblyGroups`) - `Prism.Modularity` (`IModule`, `IContainerProvider`, `IContainerRegistry`) - `Unity` (`IUnityContainer`) - `System.Windows.Media.Imaging` (`BitmapImage`) #### **Depended on by** - The Prism bootstrapper/container infrastructure (via `[Export(typeof(IModule))]` and `[Module(...)]` attributes). - UI components that resolve `IGroupImport*View` or `IGroupImportViewModel`. - The main application shell or module catalog system that consumes `GroupImageAttribute` to display module metadata. --- ### 5. **Gotchas** - **`RegisterTypes` does not use `IContainerRegistry`**: Despite implementing `IContainerRegistry`, the method ignores it and calls `Initialize()`, which uses the injected `IUnityContainer`. This is inconsistent with Prism’s recommended pattern (where `RegisterTypes` should use `containerRegistry`) and may cause confusion or breakage if the module is used in a non-Unity Prism setup. - **`AssemblyRegion` is unimplemented**: Both `AssemblyRegion` and `GetAssemblyRegion()` throw `NotImplementedException`. If the UI or module loader relies on this property, it will crash at runtime. - **Redundant constructor**: The `GroupImageAttribute(string s)` constructor accepts a parameter that is never used. - **No validation of image loading**: `AssemblyInfo.GetImage(...)` may return `null` if the image resource is missing; this is not handled, potentially leading to `NullReferenceException` at runtime when the image is rendered. - **No documentation on view/view model responsibilities**: While the types are registered, their roles (e.g., what `IGroupImportImportView` vs `IGroupImportPreviewView` does) are not described here and must be inferred from their implementations. None identified beyond the above.