Files

101 lines
7.3 KiB
Markdown
Raw Permalink Normal View History

2026-04-17 14:55:32 -04:00
---
source_files:
- DataPRO/Modules/Realtime/RealtimeModule/RealtimeModule.cs
generated_at: "2026-04-16T04:47:42.954645+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "e820d21f87955579"
---
# RealtimeModule
## Documentation: RealtimeModule
---
### 1. Purpose
The `RealtimeModule` is a Prism-based modular component responsible for registering the view and view model for the *Realtime Channel Selection* UI within the application. It integrates with the Unity dependency injection container to expose `IRealtimeChannelSelectView` and `IRealtimeChannelSelectViewModel` as singleton services, enabling their reuse and injection elsewhere in the application. Additionally, it declares assembly-level metadata attributes (`RealtimeModuleNameAttribute`, `RealtimeModuleImageAttribute`) that identify the module to the host shell (e.g., for UI display on the main screen), including its name, icon, group (`Prepare`), and region (`RealtimeModuleRegion`).
---
### 2. Public Interface
#### Class: `RealtimeModule`
- **Namespace**: `RealtimeModule`
- **Base**: Implements `Prism.Modularity.IModule`
- **Attributes**:
- `[Export(typeof(IModule))]`
- `[Module(ModuleName = "RealtimeModule")]`
| Member | Signature | Description |
|--------|-----------|-------------|
| Constructor | `public RealtimeModule(IUnityContainer unityContainer)` | Injects the Unity container for later registration of types. |
| `Initialize()` | `public void Initialize()` | Registers `IRealtimeChannelSelectView``RealtimeChannelSelectView` and `IRealtimeChannelSelectViewModel``RealtimeChannelSelectViewModel` as singleton mappings in `_unityContainer`. |
| `OnInitialized(IContainerProvider containerProvider)` | `public void OnInitialized(IContainerProvider containerProvider)` | Empty implementation; no logic executed. |
| `RegisterTypes(IContainerRegistry containerRegistry)` | `public void RegisterTypes(IContainerRegistry containerRegistry)` | Delegates to `Initialize()`, which uses the injected `IUnityContainer` (note: `containerRegistry` is unused). |
#### Class: `RealtimeModuleNameAttribute`
- **Namespace**: `RealtimeModule`
- **Base**: `TextAttribute` (from `DTS.Common.Interface`)
- **Usage**: `[assembly: RealtimeModuleName]`
| Member | Signature | Description |
|--------|-----------|-------------|
| Constructor | `public RealtimeModuleNameAttribute(string s = null)` | Initializes; `AssemblyName` is set to `AssemblyNames.RealtimeModule.ToString()`. |
| `AssemblyName` | `public override string AssemblyName { get; }` | Returns `"RealtimeModule"` (value of `AssemblyNames.RealtimeModule.ToString()`). |
| `GetAttributeType()` | `public override Type GetAttributeType()` | Returns `typeof(TextAttribute)`. |
| `GetAssemblyName()` | `public override string GetAssemblyName()` | Returns `AssemblyName`. |
#### Class: `RealtimeModuleImageAttribute`
- **Namespace**: `RealtimeModule`
- **Base**: `ImageAttribute` (from `DTS.Common.Interface`)
- **Usage**: `[assembly: RealtimeModuleImageAttribute]`
| Member | Signature | Description |
|--------|-----------|-------------|
| Constructor | `public RealtimeModuleImageAttribute(string s = null)` | Initializes `_img` by calling `AssemblyInfo.GetImage("RealtimeModule")`. |
| `AssemblyImage` | `public override BitmapImage AssemblyImage { get; }` | Returns `_img`, lazily initialized via `AssemblyInfo.GetImage("RealtimeModule")`. |
| `AssemblyName` | `public override string AssemblyName { get; }` | Returns `"RealtimeModule"`. |
| `AssemblyGroup` | `public override string AssemblyGroup { get; }` | Returns `"Prepare"` (value of `eAssemblyGroups.Prepare.ToString()`). |
| `AssemblyRegion` | `public override eAssemblyRegion AssemblyRegion { get; }` | Returns `eAssemblyRegion.RealtimeModuleRegion`. |
| `GetAttributeType()` | `public override Type GetAttributeType()` | Returns `typeof(ImageAttribute)`. |
| `GetAssemblyImage()` | `public override BitmapImage GetAssemblyImage()` | Returns `AssemblyImage`. |
| `GetAssemblyName()` | `public override string GetAssemblyName()` | Returns `AssemblyName`. |
| `GetAssemblyGroup()` | `public override string GetAssemblyGroup()` | Returns `AssemblyGroup`. |
| `GetAssemblyRegion()` | `public override eAssemblyRegion GetAssemblyRegion()` | Returns `AssemblyRegion`. |
---
### 3. Invariants
- `RealtimeModule` **must** be loaded *after* the Unity container is available (via Prisms module initialization lifecycle), as `Initialize()` relies on `_unityContainer` being non-null.
- `AssemblyNames.RealtimeModule` and `eAssemblyGroups.Prepare` and `eAssemblyRegion.RealtimeModuleRegion` must be defined in referenced assemblies (`DTS.Common`, `DTS.Common.Interface`) — their values are *not* defined in this file.
- `AssemblyInfo.GetImage(string)` is assumed to return a valid `BitmapImage` for `"RealtimeModule"`; failure here would cause runtime exceptions during attribute instantiation.
- The view/view model registrations in `Initialize()` are **singleton** (default Unity behavior for `RegisterType<T, TImpl>()` without explicit lifetime manager).
---
### 4. Dependencies
#### This module depends on:
- `Unity` (`IUnityContainer`) — for DI registration.
- `Prism.Modularity` (`IModule`, `IContainerProvider`, `IContainerRegistry`) — module lifecycle integration.
- `DTS.Common` and `DTS.Common.Interface` — for `AssemblyNames`, `eAssemblyGroups`, `eAssemblyRegion`, `TextAttribute`, `ImageAttribute`, and `AssemblyInfo.GetImage(...)`.
- `System.Windows.Media.Imaging` — for `BitmapImage`.
#### This module is depended on by:
- The Prism bootstrapper/module catalog — via `[Export(typeof(IModule))]` and `[Module(...)]` attributes.
- Any consumer requiring `IRealtimeChannelSelectView` or `IRealtimeChannelSelectViewModel` — these are registered as singletons.
- The host shell/UI — via `RealtimeModuleImageAttribute` and `RealtimeModuleNameAttribute`, used to render module metadata (e.g., in a module summary panel).
---
### 5. Gotchas
- **Redundant `Initialize()` call**: `RegisterTypes()` calls `Initialize()`, but `Initialize()` uses `_unityContainer` (injected via constructor), while `RegisterTypes()` receives `IContainerRegistry`. This suggests potential confusion or legacy code: `IContainerRegistry` is unused, and the method relies on the *old* `IUnityContainer` instance. This may cause issues if `RegisterTypes()` is invoked before `_unityContainer` is set (though Prism guarantees `Initialize()` runs first).
- **No `OnInitialized()` logic**: The `OnInitialized()` method is empty, but its signature implies extensibility — no further initialization is performed beyond registration.
- **Assembly image loading**: `AssemblyInfo.GetImage(...)` is called in the attribute constructor. If the image resource is missing or malformed, attribute instantiation (at assembly load time) may fail silently or throw, depending on `AssemblyInfo` implementation.
- **No versioning or deprecation markers**: Attributes lack versioning or deprecation info, making future refactoring harder to track.
- **Namespace `RealtimeModule` is reused**: The namespace matches the module name and class name — may cause confusion with the assembly name.
- **`AllowMultiple = false` on attributes**: Only one instance of each attribute is allowed per assembly — expected, but not enforced at compile time.
None identified beyond the above.