--- source_files: - DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.AddCalculatedChannel/AddCalculatedChannelModule.cs generated_at: "2026-04-16T11:07:19.006418+00:00" model: "zai-org/GLM-5-FP8" schema_version: 1 sha256: "a6eff6c72a8470eb" --- # Documentation: AddCalculatedChannelModule ## 1. Purpose This module provides the "Add Calculated Channel" functionality for the DTS Viewer application. It is a Prism module responsible for registering its associated View (`AddCalculatedChannelView`) and ViewModel (`AddCalculatedChannelViewModel`) with the Unity dependency injection container. The module also defines assembly-level metadata attributes that expose the module's name, image, group, and region for use by the main application shell. --- ## 2. Public Interface ### `AddCalculatedChannelModule` (Class) Implements `Prism.Modularity.IModule`. The primary module entry point. | Member | Signature | Description | |--------|-----------|-------------| | Constructor | `AddCalculatedChannelModule(IUnityContainer unityContainer)` | Accepts an injected `IUnityContainer` instance and stores it in `_unityContainer`. | | `RegisterTypes` | `void RegisterTypes(IContainerRegistry containerRegistry)` | Calls `Initialize()`. Required by `IModule`. | | `OnInitialized` | `void OnInitialized(IContainerProvider containerProvider)` | Empty implementation. Required by `IModule`. | | `Initialize` | `void Initialize()` | Registers `IAddCalculatedChannelView` → `AddCalculatedChannelView` and `IAddCalculatedChannelViewModel` → `AddCalculatedChannelViewModel` with Unity. | ### `AddCalculatedChannelModuleNameAttribute` (Class) Extends `TextAttribute`. Applied at assembly level to expose the module name. | Member | Signature | Description | |--------|-----------|-------------| | Constructor | `AddCalculatedChannelModuleNameAttribute()` | Default constructor. | | Constructor | `AddCalculatedChannelModuleNameAttribute(string s)` | Overload accepting a string (parameter is unused). | | `AssemblyName` | `override string AssemblyName { get; }` | Returns `AssemblyNames.AddCalculatedChannel.ToString()`. | | `GetAttributeType` | `override Type GetAttributeType()` | Returns `typeof(TextAttribute)`. | | `GetAssemblyName` | `override string GetAssemblyName()` | Returns `AssemblyName`. | ### `AddCalculatedChannelModuleImageAttribute` (Class) Extends `ImageAttribute`. Applied at assembly level to expose module image, name, group, and region metadata. | Member | Signature | Description | |--------|-----------|-------------| | Constructor | `AddCalculatedChannelModuleImageAttribute()` | Default constructor. | | Constructor | `AddCalculatedChannelModuleImageAttribute(string s)` | Overload accepting a string (parameter is unused). | | `AssemblyImage` | `override BitmapImage AssemblyImage { get; }` | Lazily loads image via `AssemblyInfo.GetImage()`. | | `AssemblyName` | `override string AssemblyName { get; }` | Returns `AssemblyNames.AddCalculatedChannel.ToString()`. | | `AssemblyGroup` | `override string AssemblyGroup { get; }` | Returns `eAssemblyGroups.Viewer.ToString()`. | | `AssemblyRegion` | `override eAssemblyRegion AssemblyRegion { get; }` | Returns `eAssemblyRegion.AddCalculatedChannelRegion`. | | `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 - **Module Name**: The Prism module name is the string literal `"AddCalculatedChannel"` (set via `[Module(ModuleName = "AddCalculatedChannel")]`). - **Single Instance Attributes**: Both assembly attributes are declared with `AllowMultiple = false`, ensuring only one of each exists per assembly. - **Region Assignment**: The module is always associated with `eAssemblyRegion.AddCalculatedChannelRegion`. - **Group Assignment**: The module always belongs to `eAssemblyGroups.Viewer`. - **Interface Registration**: Types are registered by interface (`IAddCalculatedChannelView`, `IAddCalculatedChannelViewModel`) rather than concrete types. --- ## 4. Dependencies ### This module depends on: - `System` - Core .NET framework. - `System.Windows.Media.Imaging` - For `BitmapImage` used in module image. - `DTS.Common` - Provides `AssemblyNames` enum and `eAssemblyGroups`, `eAssemblyRegion` enums. - `DTS.Common.Interface` - Provides `TextAttribute`, `ImageAttribute`, and `AssemblyInfo` base classes/utilities. - `Prism.Ioc` - For `IContainerProvider` and `IContainerRegistry`. - `Prism.Modularity` - For `IModule` interface and `ModuleAttribute`. - `Unity` - For `IUnityContainer` DI container. ### What depends on this module: - **Inferred**: The main DTS Viewer shell application, which discovers and loads Prism modules via assembly attributes and registers Views/ViewModels for navigation. - **Inferred**: `IAddCalculatedChannelView` and `IAddCalculatedChannelViewModel` consumers (likely defined in `DTS.Common.Interface` or elsewhere). --- ## 5. Gotchas 1. **Misleading Singleton Comment**: The comment on line 42 states "Register View & View-Model with Unity dependency injection container as a singleton," but `_unityContainer.RegisterType()` without a `ContainerControlledLifetimeManager` registers types as **transient**, not singleton. The comment appears inaccurate relative to the actual code behavior. 2. **Unused Constructor Parameter**: Both attribute classes have constructors accepting a `string s` parameter that is never used. This is likely required by attribute syntax constraints but serves no functional purpose. 3. **Redundant Image Initialization**: In `AddCalculatedChannelModuleImageAttribute`, the `_img` field is initialized both in the constructor and lazily in the `AssemblyImage` getter. The constructor initialization is overwritten by the getter on first access. 4. **Empty `OnInitialized`**: The `OnInitialized` method is intentionally empty. This is valid but may indicate initialization logic is handled elsewhere or deferred. 5. **ReSharper Suppressions**: The file includes `// ReSharper disable` directives for `RedundantAttributeUsageProperty` and `UnusedParameter.Local`, suggesting known code style issues that were suppressed rather than addressed.