Files

97 lines
6.3 KiB
Markdown
Raw Permalink Normal View History

2026-04-17 14:55:32 -04:00
---
source_files:
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.ChartOptions/ChartOptionsModule.cs
generated_at: "2026-04-16T11:06:39.911928+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 the chart options View, ViewModel, and Model with the Unity dependency injection container, and provides assembly-level metadata (name, image, group, and region) that the main application uses to identify and display this module as an available component.
---
## 2. Public Interface
### `ChartOptionsModule` (Class)
Implements `Prism.Modularity.IModule`. The primary module entry point for the ChartOptions feature.
| Member | Signature | Description |
|--------|-----------|-------------|
| Constructor | `ChartOptionsModule(IUnityContainer unityContainer)` | Accepts an injected `IUnityContainer` instance and stores it in `_unityContainer`. |
| `RegisterTypes` | `void RegisterTypes(IContainerRegistry containerRegistry)` | Calls `Initialize()` to perform type registrations. Required by `IModule`. |
| `OnInitialized` | `void OnInitialized(IContainerProvider containerProvider)` | Empty implementation. Required by `IModule`. |
| `Initialize` | `void Initialize()` | Registers three type mappings with Unity: `IChartOptionsView``ChartOptionsView`, `IChartOptionsViewModel``ChartOptionsViewModel`, `IChartOptionsModel``ChartOptionsModel`. |
### `ChartOptionsModuleNameAttribute` (Class)
Inherits from `TextAttribute`. Assembly-level attribute providing the module's name.
| Member | Signature | Description |
|--------|-----------|-------------|
| Constructor | `ChartOptionsModuleNameAttribute()` | Default constructor. |
| Constructor | `ChartOptionsModuleNameAttribute(string s)` | Overloaded constructor; parameter `s` is unused. |
| `AssemblyName` | `override string AssemblyName { get; }` | Returns `AssemblyNames.ChartOptions.ToString()`. |
| `GetAttributeType` | `override Type GetAttributeType()` | Returns `typeof(TextAttribute)`. |
| `GetAssemblyName` | `override string GetAssemblyName()` | Returns `AssemblyName`. |
### `ChartOptionsModuleImageAttribute` (Class)
Inherits from `ImageAttribute`. Assembly-level attribute providing the module's image, name, group, and region metadata.
| Member | Signature | Description |
|--------|-----------|-------------|
| Constructor | `ChartOptionsModuleImageAttribute()` | Default constructor. |
| Constructor | `ChartOptionsModuleImageAttribute(string s)` | Overloaded constructor; parameter `s` is unused. |
| `AssemblyImage` | `override BitmapImage AssemblyImage { get; }` | Lazily loads and returns 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`. |
| `GetAssemblyName` | `override string GetAssemblyName()` | Returns `AssemblyName`. |
| `GetAssemblyGroup` | `override string GetAssemblyGroup()` | Returns `AssemblyGroup`. |
| `GetAssemblyRegion` | `override eAssemblyRegion GetAssemblyRegion()` | Returns `AssemblyRegion`. |
---
## 3. Invariants
- The module is registered with Prism under the name `"DTS.Viewer.ChartOptions"`.
- Both assembly attributes are applied with `AllowMultiple = false`, ensuring exactly one instance of each attribute per assembly.
- `AssemblyName` for both attributes always returns `AssemblyNames.ChartOptions.ToString()`.
- `AssemblyGroup` for `ChartOptionsModuleImageAttribute` always returns `eAssemblyGroups.Viewer.ToString()`.
- `AssemblyRegion` for `ChartOptionsModuleImageAttribute` always returns `eAssemblyRegion.ChartOptionsRegion`.
- Type registrations occur exactly once during module initialization via `RegisterTypes`.
---
## 4. Dependencies
### This Module Depends On:
- `System` - Core .NET framework.
- `System.Windows.Media.Imaging` - For `BitmapImage` used in module image.
- `DTS.Common` - Likely contains `AssemblyNames` enum and `AssemblyInfo` utility class.
- `DTS.Common.Interface` - Contains `TextAttribute`, `ImageAttribute`, `eAssemblyGroups`, and `eAssemblyRegion`.
- `DTS.Viewer.ChartOptions.Model` - Contains `IChartOptionsModel` and `ChartOptionsModel` (inferred from usage).
- `Prism.Ioc` - For `IContainerProvider` and `IContainerRegistry`.
- `Prism.Modularity` - For `IModule` and `ModuleAttribute`.
- `Unity` - For `IUnityContainer` and DI registration.
### What Depends On This Module:
- The main DTS Viewer application shell, which discovers and loads this module via Prism's module system.
- The `ChartOptionsView`, `ChartOptionsViewModel`, and `ChartOptionsModel` implementations (referenced but not defined in this file).
---
## 5. Gotchas
1. **Comment claims singleton, code does not enforce it**: The comment in `Initialize()` states "Register View & View-Model with Unity dependency injection container as a singleton," but `RegisterType` without a `ContainerControlledLifetimeManager` registers types as transient (new instance per resolve), not singleton. If singleton behavior is intended, this is a bug.
2. **Unused constructor parameters**: Both `ChartOptionsModuleNameAttribute(string s)` and `ChartOptionsModuleImageAttribute(string s)` accept a string parameter that is never used. This may be dead code or a remnant of a base class contract.
3. **Side effects in property getters**: `AssemblyImage` property has a side effect of assigning to the private `_img` field on every get. Similarly, `_name` and `_group` are assigned in their respective property getters. This is unconventional and could cause unexpected behavior if properties are accessed multiple times.
4. **Empty `OnInitialized` implementation**: The `OnInitialized` method is required by `IModule` but is empty. It is unclear whether this is intentional or represents incomplete initialization logic.