--- source_files: - DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.Navigation/NavigationModule.cs generated_at: "2026-04-16T13:45:08.040619+00:00" model: "zai-org/GLM-5-FP8" schema_version: 1 sha256: "b8a48119ee42a5bd" --- # Documentation: DTS.Viewer.Navigation Module ## 1. Purpose This module provides navigation functionality for the DTS Viewer application. It is a Prism module (`NavigationModule`) responsible for registering the navigation view and view-model with the Unity dependency injection container. The module also defines assembly-level metadata attributes (`NavigationPropertiesNameAttribute`, `NavigationPropertiesImageAttribute`) that expose the module's name, icon, group, and region information to the main application shell for display and routing purposes. --- ## 2. Public Interface ### `NavigationModule` Class A Prism `IModule` implementation that handles module initialization and type registration. | Member | Signature | Description | |--------|-----------|-------------| | Constructor | `NavigationModule(IUnityContainer unityContainer)` | Accepts a Unity container via dependency injection and stores it in a private readonly field `_unityContainer`. | | `RegisterTypes` | `void RegisterTypes(IContainerRegistry containerRegistry)` | Implements `IModule.RegisterTypes`. Delegates to `Initialize()`. | | `OnInitialized` | `void OnInitialized(IContainerProvider containerProvider)` | Implements `IModule.OnInitialized`. Currently empty with no implementation. | | `Initialize` | `void Initialize()` | Registers `INavigationView` → `NavigationView` and `INavigationViewModel` → `NavigationViewModel` mappings with Unity via `RegisterType()`. | **Module Metadata:** - Decorated with `[Module(ModuleName = "NavigationProperties")]` --- ### `NavigationPropertiesNameAttribute` Class An assembly-level attribute extending `TextAttribute` that provides the module's display name. | Member | Signature | Description | |--------|-----------|-------------| | Constructor | `NavigationPropertiesNameAttribute()` | Default constructor. Sets `_assemblyName` to `AssemblyNames.Navigation.ToString()`. | | Constructor | `NavigationPropertiesNameAttribute(string s)` | Overloaded constructor accepting a string parameter (parameter is unused). | | `AssemblyName` | `override string AssemblyName { get; }` | Returns `_assemblyName` (value of `AssemblyNames.Navigation.ToString()`). | | `GetAttributeType` | `override Type GetAttributeType()` | Returns `typeof(TextAttribute)`. | | `GetAssemblyName` | `override string GetAssemblyName()` | Returns `AssemblyName` property value. | **Attribute Usage:** `AttributeTargets.Assembly`, `AllowMultiple = false` --- ### `NavigationPropertiesImageAttribute` Class An assembly-level attribute extending `ImageAttribute` that provides the module's icon, name, group, and region metadata. | Member | Signature | Description | |--------|-----------|-------------| | Constructor | `NavigationPropertiesImageAttribute()` | Default constructor. Initializes `_img` via `AssemblyInfo.GetImage(AssemblyNames.Navigation.ToString())`. | | Constructor | `NavigationPropertiesImageAttribute(string s)` | Overloaded constructor accepting a string parameter (parameter is unused). | | `AssemblyImage` | `override BitmapImage AssemblyImage { get; }` | Getter re-assigns `_img` via `AssemblyInfo.GetImage(...)` then returns it. | | `AssemblyName` | `override string AssemblyName { get; }` | Returns `AssemblyNames.Navigation.ToString()`. | | `AssemblyGroup` | `override string AssemblyGroup { get; }` | Returns `eAssemblyGroups.Viewer.ToString()`. | | `AssemblyRegion` | `override eAssemblyRegion AssemblyRegion { get; }` | Returns `eAssemblyRegion.NavigationRegion`. | | `GetAttributeType` | `override Type GetAttributeType()` | Returns `typeof(ImageAttribute)`. | | `GetAssemblyImage` | `override BitmapImage GetAssemblyImage()` | Returns `AssemblyImage` property. | | `GetAssemblyName` | `override string GetAssemblyName()` | Returns `AssemblyName` property. | | `GetAssemblyRegion` | `override eAssemblyRegion GetAssemblyRegion()` | Returns `AssemblyRegion` property. | | `GetAssemblyGroup` | `override string GetAssemblyGroup()` | Returns `AssemblyGroup` property. | **Attribute Usage:** `AttributeTargets.Assembly`, `AllowMultiple = false` --- ## 3. Invariants - The module must be instantiated with a non-null `IUnityContainer` reference (constructor injection). - `NavigationView` and `NavigationViewModel` must implement `INavigationView` and `INavigationViewModel` interfaces respectively (required for `RegisterType<,>()` calls). - Assembly attributes are applied exactly once per assembly (`AllowMultiple = false`). - The enum values `AssemblyNames.Navigation`, `eAssemblyGroups.Viewer`, and `eAssemblyRegion.NavigationRegion` must be defined in external assemblies (`DTS.Common`). - The static method `AssemblyInfo.GetImage(string)` must be available and return a valid `BitmapImage`. --- ## 4. Dependencies ### This Module Depends On: - **Prism.Ioc** — `IContainerProvider`, `IContainerRegistry` - **Prism.Modularity** — `IModule`, `ModuleAttribute` - **Unity** — `IUnityContainer` - **System.Windows.Media.Imaging** — `BitmapImage` - **DTS.Common** — `AssemblyNames` (enum), `eAssemblyRegion` (enum), `eAssemblyGroups` (enum), `AssemblyInfo` (static class with `GetImage` method) - **DTS.Common.Interface** — `TextAttribute`, `ImageAttribute` (base classes) ### What Depends On This Module: - **`NavigationView`** — Concrete view class (referenced but not defined in this file) - **`NavigationViewModel`** — Concrete view-model class (referenced but not defined in this file) - **`INavigationView`** — Interface (referenced but not defined in this file) - **`INavigationViewModel`** — Interface (referenced but not defined in this file) - The main application shell (consumes assembly attributes for module discovery and display) --- ## 5. Gotchas 1. **Misleading Comment:** The comment on line 38 states "Register View & View-Model with Unity dependency injection container as a singleton." However, `RegisterType()` registers types as **transient**, not singleton. To register as singleton, `RegisterSingleton()` or `RegisterInstance()` should be used. 2. **Unused Constructor Parameters:** Both attribute classes have constructors accepting a `string s` parameter that is never used. This appears to be dead code, possibly required by attribute syntax conventions or leftover from refactoring. 3. **Side Effect in Property Getter:** The `AssemblyImage` property getter has a side effect—it reassigns `_img` every time it is called. This is unusual and could cause unnecessary image reloading if the property is accessed multiple times. 4. **Empty `OnInitialized` Implementation:** The `OnInitialized` method is intentionally empty. It is unclear whether this is by design or incomplete implementation. 5. **Redundant Method Call:** `RegisterTypes()` simply delegates to `Initialize()`. While this satisfies the Prism module contract, the separation between these methods serves no functional purpose in this implementation.