Files

88 lines
6.0 KiB
Markdown
Raw Permalink Normal View History

2026-04-17 14:55:32 -04:00
---
source_files:
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.Graph/GraphModule.cs
generated_at: "2026-04-16T11:05:54.984178+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "b6bfcd5e53808ea8"
---
# Documentation: DTS.Viewer.Graph Module
## 1. Purpose
This module serves as the Prism module definition for the `DTS.Viewer.Graph` component within the DTS Viewer application. Its primary role is to register graph-related views and view models with the Unity dependency injection container during application startup. Additionally, it defines assembly-level attributes (`GraphNameAttribute` and `GraphImageAttribute`) that provide metadata—such as the assembly name, display image, and region assignment—likely used by the main application shell to dynamically discover and display this module.
## 2. Public Interface
### Classes
#### `GraphModule`
Implements `Prism.Modularity.IModule`. The entry point for the module's configuration.
* **`GraphModule(IUnityContainer unityContainer)`**
* Constructor that accepts an `IUnityContainer` instance via dependency injection and stores it in a readonly field.
* **`void RegisterTypes(IContainerRegistry containerRegistry)`**
* Implements `IModule.RegisterTypes`. Calls the local `Initialize()` method to perform type registrations. Note that it ignores the passed `IContainerRegistry` in favor of the stored `IUnityContainer`.
* **`void OnInitialized(IContainerProvider containerProvider)`**
* Implements `IModule.OnInitialized`. Currently contains no implementation logic.
* **`void Initialize()`**
* Registers types with the Unity container.
* **Mappings:**
* `IGraphView``GraphView`
* `IGraphViewModel``GraphViewModel`
* `ITestDataSeriesView``TestDataSeriesView`
* `ITestDataSeriesViewModel``TestDataSeriesViewModel`
#### `GraphNameAttribute`
Inherits from `DTS.Common.Interface.TextAttribute`. Applied at the assembly level to define the module's name.
* **`GraphNameAttribute()`**
* Default constructor. Sets the internal assembly name to `AssemblyNames.Graph.ToString()`.
* **`GraphNameAttribute(string s)`**
* Overloaded constructor. The parameter `s` is accepted but ignored; the assembly name is hardcoded to `AssemblyNames.Graph.ToString()`.
* **`override string AssemblyName`** (Property)
* Returns the stored assembly name string.
* **`override Type GetAttributeType()`**
* Returns `typeof(TextAttribute)`.
* **`override string GetAssemblyName()`**
* Returns the `AssemblyName` property value.
#### `GraphImageAttribute`
Inherits from `DTS.Common.Interface.ImageAttribute`. Applied at the assembly level to provide display metadata (image, group, region).
* **`GraphImageAttribute()` / `GraphImageAttribute(string s)`**
* Constructors. The string parameter `s` is ignored. Initializes the image using `AssemblyInfo.GetImage`.
* **`override BitmapImage AssemblyImage`** (Property)
* Loads and returns a `BitmapImage` by calling `AssemblyInfo.GetImage(AssemblyNames.Graph.ToString())`.
* **`override string AssemblyName`** (Property)
* Returns `AssemblyNames.Graph.ToString()`.
* **`override string AssemblyGroup`** (Property)
* Returns `eAssemblyGroups.Viewer.ToString()`.
* **`override eAssemblyRegion AssemblyRegion`** (Property)
* Returns `eAssemblyRegion.GraphRegion`.
* **Methods:** `GetAttributeType()`, `GetAssemblyImage()`, `GetAssemblyName()`, `GetAssemblyGroup()`, `GetAssemblyRegion()` return the values of the respective properties described above.
## 3. Invariants
* **Module Name:** The module is identified by the string "Graph" via the `[Module(ModuleName = "Graph")]` attribute.
* **Attribute Uniqueness:** `GraphNameAttribute` and `GraphImageAttribute` are applied at the assembly level with `AllowMultiple = false`, ensuring only one instance of each exists per assembly.
* **Naming Consistency:** Both attribute classes hardcode the assembly name lookup to `AssemblyNames.Graph`, ensuring the metadata matches the module identity.
* **Region Assignment:** The module is statically assigned to `eAssemblyRegion.GraphRegion`.
## 4. Dependencies
### Internal Dependencies
* **`DTS.Common`**: Uses `AssemblyNames`, `eAssemblyGroups`, `eAssemblyRegion`, and `AssemblyInfo`.
* **`DTS.Common.Interface`**: Defines base classes `TextAttribute`, `ImageAttribute` and interfaces `IGraphView`, `IGraphViewModel`, `ITestDataSeriesView`, `ITestDataSeriesViewModel`.
* **Local Views/ViewModels**: References `GraphView`, `GraphViewModel`, `TestDataSeriesView`, `TestDataSeriesViewModel` (types not provided in source, but referenced in `Initialize`).
### External Dependencies
* **`Prism.Ioc`**: Uses `IContainerProvider`, `IContainerRegistry`.
* **`Prism.Modularity`**: Implements `IModule`.
* **`Unity`**: Uses `IUnityContainer` and `Unity` attributes.
* **`System.Windows.Media.Imaging`**: Uses `BitmapImage` for image handling.
## 5. Gotchas
* **Unused Constructor Parameters:** Both `GraphNameAttribute(string s)` and `GraphImageAttribute(string s)` accept a string parameter that is completely ignored. This suggests a legacy API or a design intended for future expansion that was never implemented.
* **Side Effects in Property Getters:** The `AssemblyImage` property getter in `GraphImageAttribute` performs logic (`_img = AssemblyInfo.GetImage(...)`). Accessing this property triggers image loading every time, which could be a performance concern if accessed frequently, though the private field `_img` is reassigned each time.
* **Mixed Container Abstractions:** The `RegisterTypes` method receives an `IContainerRegistry` (Prism abstraction) but ignores it. Instead, it calls `Initialize()`, which uses the concrete `IUnityContainer` injected via the constructor. This bypasses Prism's container abstraction, making it harder to swap containers later.
* **Commented Code:** The `Initialize` method contains commented-out registrations for `ITestDataView` and `ITestDataViewModel`. It is unclear if this is dead code or a feature in progress.