--- source_files: - DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.Graph/GraphModule.cs generated_at: "2026-04-16T13:43:35.728588+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`, `GraphImageAttribute`) that provide metadata—such as the assembly name, display image, and region assignment—used by the main application shell to identify and display the Graph module. ## 2. Public Interface ### Class: `GraphModule` Implements `Prism.Modularity.IModule`. It is 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)`** * Implementation of the `IModule` interface. It invokes the `Initialize()` method to perform type registrations. Note that it ignores the passed `IContainerRegistry` and uses the injected `IUnityContainer` instead. * **`void OnInitialized(IContainerProvider containerProvider)`** * Implementation of the `IModule` interface. Currently contains no implementation logic. * **`void Initialize()`** * Registers types with the Unity container. It maps interfaces to concrete implementations for the following pairs: * `IGraphView` → `GraphView` * `IGraphViewModel` → `GraphViewModel` * `ITestDataSeriesView` → `TestDataSeriesView` * `ITestDataSeriesViewModel` → `TestDataSeriesViewModel` ### Class: `GraphNameAttribute` Inherits from `DTS.Common.Interface.TextAttribute`. Applied at the assembly level to provide the module's name. * **`GraphNameAttribute()`** * Default constructor. Initializes the internal `_assemblyName` field using `AssemblyNames.Graph.ToString()`. * **`string AssemblyName`** (Property) * Returns the stored assembly name string. * **`Type GetAttributeType()`** * Returns `typeof(TextAttribute)`. * **`string GetAssemblyName()`** * Returns the `AssemblyName` property value. ### Class: `GraphImageAttribute` Inherits from `DTS.Common.Interface.ImageAttribute`. Applied at the assembly level to provide display metadata. * **`BitmapImage AssemblyImage`** (Property) * Gets the module's image by calling `AssemblyInfo.GetImage(AssemblyNames.Graph.ToString())`. * **`string AssemblyName`** (Property) * Returns `AssemblyNames.Graph.ToString()`. * **`string AssemblyGroup`** (Property) * Returns `eAssemblyGroups.Viewer.ToString()`. * **`eAssemblyRegion AssemblyRegion`** (Property) * Returns `eAssemblyRegion.GraphRegion`. * **`BitmapImage GetAssemblyImage()`**, **`string GetAssemblyName()`**, **`string GetAssemblyGroup()`**, **`eAssemblyRegion GetAssemblyRegion()`** * Accessor methods returning the values of their corresponding properties described above. ## 3. Invariants * **Container Consistency:** The module relies strictly on `IUnityContainer` for registration, despite `RegisterTypes` providing a generic `IContainerRegistry`. * **Metadata Constants:** The `AssemblyName` is always derived from the `AssemblyNames.Graph` enum value. The `AssemblyGroup` is always `eAssemblyGroups.Viewer`, and the `AssemblyRegion` is always `eAssemblyRegion.GraphRegion`. * **Attribute Usage:** Both `GraphNameAttribute` and `GraphImageAttribute` are decorated with `AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)`, ensuring single-instance application at the assembly level. ## 4. Dependencies ### Internal Dependencies (Inferred) * **`DTS.Common`**: Used for `AssemblyNames`, `eAssemblyGroups`, `eAssemblyRegion`, and `AssemblyInfo`. * **`DTS.Common.Interface`**: Defines `TextAttribute`, `ImageAttribute`, and the view/view model interfaces (`IGraphView`, `IGraphViewModel`, `ITestDataSeriesView`, `ITestDataSeriesViewModel`). * **Local Types**: The module registers but does not define `GraphView`, `GraphViewModel`, `TestDataSeriesView`, and `TestDataSeriesViewModel`. ### External Dependencies * **`Prism.Ioc`**: Provides `IContainerProvider`, `IContainerRegistry`. * **`Prism.Modularity`**: Provides `IModule`, `ModuleAttribute`. * **`Unity`**: Provides `IUnityContainer`. * **`System.Windows.Media.Imaging`**: Provides `BitmapImage`. ## 5. Gotchas * **Bypassing Prism Abstractions:** The `RegisterTypes` method receives an `IContainerRegistry` parameter (standard Prism abstraction) but completely ignores it. Instead, it calls `Initialize()`, which uses the constructor-injected `IUnityContainer`. This tightly couples the module to the Unity container, defeating the purpose of Prism's container-agnostic `IContainerRegistry` interface. * **Dead Code:** The `Initialize` method contains commented-out registrations for `ITestDataView` and `ITestDataViewModel`. This suggests incomplete refactoring or deprecated features that have not been removed. * **Unused Constructor Parameters:** The constructors for `GraphNameAttribute(string s)` and `GraphImageAttribute(string s)` accept a string parameter `s` that is never used. The default constructors call these overloaded constructors with `null`, and the logic inside them ignores the argument entirely. * **Property Side-Effects:** In `GraphImageAttribute`, the getter for `AssemblyImage` performs logic (`_img = AssemblyInfo.GetImage...`) rather than simply returning a cached value. While likely harmless, this means the image fetching logic runs every time the property is accessed, rather than just once in the constructor.