94 lines
6.4 KiB
Markdown
94 lines
6.4 KiB
Markdown
|
|
---
|
||
|
|
source_files:
|
||
|
|
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.ChartOptions/ChartOptionsModule.cs
|
||
|
|
generated_at: "2026-04-16T13:44:59.673795+00:00"
|
||
|
|
model: "zai-org/GLM-5-FP8"
|
||
|
|
schema_version: 1
|
||
|
|
sha256: "bcd5ac559d7f6d8e"
|
||
|
|
---
|
||
|
|
|
||
|
|
# Documentation: ChartOptionsModule.cs
|
||
|
|
|
||
|
|
## 1. Purpose
|
||
|
|
|
||
|
|
This module serves as the Prism module initializer for the `DTS.Viewer.ChartOptions` component within the DTS Viewer application. It is responsible for registering chart options-related views, view models, and models with the Unity dependency injection container, and provides assembly-level metadata (name, image, group, region) that the main application uses to discover and display this module as an available component.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 2. Public Interface
|
||
|
|
|
||
|
|
### `ChartOptionsModule` Class
|
||
|
|
Implements `Prism.Modularity.IModule`. The primary module entry point.
|
||
|
|
|
||
|
|
| Member | Signature | Description |
|
||
|
|
|--------|-----------|-------------|
|
||
|
|
| Constructor | `ChartOptionsModule(IUnityContainer unityContainer)` | Accepts an injected Unity container reference. |
|
||
|
|
| `RegisterTypes` | `void RegisterTypes(IContainerRegistry containerRegistry)` | Registers types with the container. Calls `Initialize()`. |
|
||
|
|
| `OnInitialized` | `void OnInitialized(IContainerProvider containerProvider)` | Empty implementation (no post-initialization logic). |
|
||
|
|
| `Initialize` | `void Initialize()` | Registers `IChartOptionsView` → `ChartOptionsView`, `IChartOptionsViewModel` → `ChartOptionsViewModel`, and `IChartOptionsModel` → `ChartOptionsModel` with Unity. |
|
||
|
|
|
||
|
|
### `ChartOptionsModuleNameAttribute` Class
|
||
|
|
Extends `TextAttribute`. Applied at assembly level to provide the module's display name.
|
||
|
|
|
||
|
|
| Member | Signature | Description |
|
||
|
|
|--------|-----------|-------------|
|
||
|
|
| Constructor | `ChartOptionsModuleNameAttribute()` | Default constructor. |
|
||
|
|
| Constructor | `ChartOptionsModuleNameAttribute(string s)` | Overload accepting a string (parameter is unused). |
|
||
|
|
| `AssemblyName` | `override string AssemblyName { get; }` | Returns `AssemblyNames.ChartOptions.ToString()`. |
|
||
|
|
| `GetAttributeType` | `override Type GetAttributeType()` | Returns `typeof(TextAttribute)`. |
|
||
|
|
| `GetAssemblyName` | `override string GetAssemblyName()` | Returns the `AssemblyName` property value. |
|
||
|
|
|
||
|
|
### `ChartOptionsModuleImageAttribute` Class
|
||
|
|
Extends `ImageAttribute`. Applied at assembly level to provide module image and categorization metadata.
|
||
|
|
|
||
|
|
| Member | Signature | Description |
|
||
|
|
|--------|-----------|-------------|
|
||
|
|
| Constructor | `ChartOptionsModuleImageAttribute()` | Default constructor. |
|
||
|
|
| Constructor | `ChartOptionsModuleImageAttribute(string s)` | Overload accepting a string (parameter is unused). |
|
||
|
|
| `AssemblyImage` | `override BitmapImage AssemblyImage { get; }` | Lazily loads image via `AssemblyInfo.GetImage(AssemblyNames.ChartOptions.ToString())`. |
|
||
|
|
| `AssemblyName` | `override string AssemblyName { get; }` | Returns `AssemblyNames.ChartOptions.ToString()`. |
|
||
|
|
| `AssemblyGroup` | `override string AssemblyGroup { get; }` | Returns `eAssemblyGroups.Viewer.ToString()`. |
|
||
|
|
| `AssemblyRegion` | `override eAssemblyRegion AssemblyRegion { get; }` | Returns `eAssemblyRegion.ChartOptionsRegion`. |
|
||
|
|
| `GetAttributeType` | `override Type GetAttributeType()` | Returns `typeof(ImageAttribute)`. |
|
||
|
|
| `GetAssemblyImage` | `override BitmapImage GetAssemblyImage()` | Returns `AssemblyImage` property. |
|
||
|
|
| `GetAssemblyName` | `override string GetAssemblyName()` | Returns `AssemblyName` property. |
|
||
|
|
| `GetAssemblyGroup` | `override string GetAssemblyGroup()` | Returns `AssemblyGroup` property. |
|
||
|
|
| `GetAssemblyRegion` | `override eAssemblyRegion GetAssemblyRegion()` | Returns `AssemblyRegion` property. |
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 3. Invariants
|
||
|
|
|
||
|
|
- **Single Instance per Attribute Type**: Both `ChartOptionsModuleNameAttribute` and `ChartOptionsModuleImageAttribute` are decorated with `AllowMultiple = false`, ensuring only one of each can be applied to the assembly.
|
||
|
|
- **Fixed Assembly Name**: The `AssemblyName` property in both attribute classes is read-only and always returns `AssemblyNames.ChartOptions.ToString()`.
|
||
|
|
- **Fixed Group Assignment**: The module is always assigned to the `Viewer` assembly group.
|
||
|
|
- **Fixed Region Assignment**: The module is always assigned to `eAssemblyRegion.ChartOptionsRegion`.
|
||
|
|
- **Container Registration**: The module always registers the same three interface-to-concrete-type mappings during initialization.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 4. Dependencies
|
||
|
|
|
||
|
|
### This Module Depends On:
|
||
|
|
- **Prism Libraries**: `Prism.Ioc`, `Prism.Modularity` (for `IModule`, `IContainerProvider`, `IContainerRegistry`)
|
||
|
|
- **Unity**: `Unity` (for `IUnityContainer`)
|
||
|
|
- **WPF**: `System.Windows.Media.Imaging` (for `BitmapImage`)
|
||
|
|
- **DTS.Common**: Likely contains `AssemblyNames` enum, `eAssemblyGroups` enum, `eAssemblyRegion` enum, and `AssemblyInfo` class.
|
||
|
|
- **DTS.Common.Interface**: Contains `TextAttribute`, `ImageAttribute` base classes.
|
||
|
|
- **DTS.Viewer.ChartOptions.Model**: Contains `IChartOptionsModel`, `ChartOptionsModel`.
|
||
|
|
- **Local Types**: `ChartOptionsView`, `ChartOptionsViewModel`, `IChartOptionsView`, `IChartOptionsViewModel` (referenced but not shown in this file).
|
||
|
|
|
||
|
|
### What Depends On This Module:
|
||
|
|
- **DTS Viewer Main Application**: Uses the assembly-level attributes to discover and display this module in the UI; resolves the registered views/view-models via the container.
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
## 5. Gotchas
|
||
|
|
|
||
|
|
1. **Comment Inaccuracy**: The comment on line 37 states "Register View & View-Model with Unity dependency injection container as a singleton." However, `_unityContainer.RegisterType<TFrom, TTo>()` without an explicit `ContainerControlledLifetimeManager` registers types as **transient**, not singleton. The comment does not match the actual behavior.
|
||
|
|
|
||
|
|
2. **Unused Constructor Parameters**: Both attribute classes have constructors accepting a `string s` parameter that is never used. This appears to be a requirement of the attribute system (attributes require parameterless constructors or constructors with constant values), but the parameter serves no functional purpose.
|
||
|
|
|
||
|
|
3. **Empty `OnInitialized` Method**: The `OnInitialized` method is explicitly implemented but empty. It is unclear whether this is intentional (no initialization logic needed) or represents incomplete implementation.
|
||
|
|
|
||
|
|
4. **Dual Initialization Pattern**: The `Initialize()` method is called from within `RegisterTypes()`. This is unconventional—typically `RegisterTypes` handles registration directly. The separate `Initialize()` method may be a legacy pattern or intended for reuse elsewhere.
|