86 lines
6.1 KiB
Markdown
86 lines
6.1 KiB
Markdown
---
|
|
source_files:
|
|
- DTS Viewer/DTS.Viewer.Modules/DTS.Viewer.Navigation/NavigationModule.cs
|
|
generated_at: "2026-04-16T11:07:35.667287+00:00"
|
|
model: "zai-org/GLM-5-FP8"
|
|
schema_version: 1
|
|
sha256: "b8a48119ee42a5bd"
|
|
---
|
|
|
|
# Documentation: DTS.Viewer.Navigation
|
|
|
|
## 1. Purpose
|
|
This module serves as the entry point for the Navigation component within 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. Additionally, it defines assembly-level attributes (`NavigationPropertiesNameAttribute`, `NavigationPropertiesImageAttribute`) that expose metadata—such as the assembly name, icon, and region assignment—to the broader application, likely for dynamic UI generation or module listing in the main shell.
|
|
|
|
## 2. Public Interface
|
|
|
|
### `NavigationModule`
|
|
The main Prism module class responsible for DI registration.
|
|
|
|
* **`NavigationModule(IUnityContainer unityContainer)`**
|
|
* Constructor that accepts an `IUnityContainer` instance via dependency injection and stores it in a private readonly field.
|
|
* **`void RegisterTypes(IContainerRegistry containerRegistry)`**
|
|
* Implements `IModule.RegisterTypes`. Calls the private `Initialize()` method to perform type registration.
|
|
* **`void OnInitialized(IContainerProvider containerProvider)`**
|
|
* Implements `IModule.OnInitialized`. Currently contains an empty implementation block.
|
|
|
|
### `NavigationPropertiesNameAttribute`
|
|
An assembly-level attribute extending `TextAttribute` used to expose the assembly name.
|
|
|
|
* **`NavigationPropertiesNameAttribute()`**
|
|
* Default constructor. Initializes the internal assembly name string.
|
|
* **`NavigationPropertiesNameAttribute(string s)`**
|
|
* Overloaded constructor accepting a string `s` (which appears to be ignored in the implementation).
|
|
* **`override string AssemblyName`**
|
|
* Property getter returning the string value of `AssemblyNames.Navigation`.
|
|
* **`override Type GetAttributeType()`**
|
|
* Returns `typeof(TextAttribute)`.
|
|
* **`override string GetAssemblyName()`**
|
|
* Returns the `AssemblyName` property value.
|
|
|
|
### `NavigationPropertiesImageAttribute`
|
|
An assembly-level attribute extending `ImageAttribute` used to expose visual metadata (image, group, region).
|
|
|
|
* **`NavigationPropertiesImageAttribute()`**
|
|
* Default constructor. Initializes the assembly image.
|
|
* **`NavigationPropertiesImageAttribute(string s)`**
|
|
* Overloaded constructor accepting a string `s` (ignored in implementation).
|
|
* **`override BitmapImage AssemblyImage`**
|
|
* Property getter that retrieves a `BitmapImage` via `AssemblyInfo.GetImage`.
|
|
* **`override string AssemblyName`**
|
|
* Returns `AssemblyNames.Navigation.ToString()`.
|
|
* **`override string AssemblyGroup`**
|
|
* Returns `eAssemblyGroups.Viewer.ToString()`.
|
|
* **`override eAssemblyRegion AssemblyRegion`**
|
|
* Returns `eAssemblyRegion.NavigationRegion`.
|
|
* **`override BitmapImage GetAssemblyImage()`**
|
|
* Returns the `AssemblyImage` property.
|
|
* **`override string GetAssemblyName()`**
|
|
* Returns the `AssemblyName` property.
|
|
* **`override eAssemblyRegion GetAssemblyRegion()`**
|
|
* Returns the `AssemblyRegion` property.
|
|
* **`override string GetAssemblyGroup()`**
|
|
* Returns the `AssemblyGroup` property.
|
|
|
|
## 3. Invariants
|
|
* **Module Name:** The `NavigationModule` is identified by the string `"NavigationProperties"` via the `[Module]` attribute.
|
|
* **Attribute Usage:** Both custom attributes are decorated with `[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)]`, ensuring only one instance of each exists per assembly.
|
|
* **Type Registration:** The `INavigationView` interface is always mapped to the `NavigationView` class, and `INavigationViewModel` is mapped to `NavigationViewModel`.
|
|
* **Metadata Constants:** The `AssemblyName` is strictly derived from `AssemblyNames.Navigation`, the `AssemblyGroup` from `eAssemblyGroups.Viewer`, and the `AssemblyRegion` from `eAssemblyRegion.NavigationRegion`.
|
|
|
|
## 4. Dependencies
|
|
**Internal Dependencies (referenced but not defined in source):**
|
|
* `DTS.Common`: Likely contains `AssemblyNames`, `eAssemblyGroups`, `eAssemblyRegion`, and `AssemblyInfo`.
|
|
* `DTS.Common.Interface`: Defines `TextAttribute`, `ImageAttribute`, `INavigationView`, and `INavigationViewModel`.
|
|
* `DTS.Viewer.Navigation` (local namespace): Contains `NavigationView` and `NavigationViewModel` classes (referenced but not shown in source).
|
|
|
|
**External Frameworks:**
|
|
* `Prism.Ioc`, `Prism.Modularity`: For module definition and DI abstractions.
|
|
* `Unity`: `IUnityContainer` for specific dependency injection implementation.
|
|
* `System.Windows.Media.Imaging`: For `BitmapImage`.
|
|
|
|
## 5. Gotchas
|
|
* **Comment/Code Mismatch (Singleton vs. Transient):** The comment in `Initialize()` states: *"Register View & View-Model ... as a singleton."* However, the code uses `_unityContainer.RegisterType<...>()`. In Unity, `RegisterType` registers a transient mapping (new instance per resolve) by default. To register as a singleton, `ContainerControlledLifetimeManager` should be used. The code does not match the intent described in the comment.
|
|
* **Ignored Constructor Parameters:** Both attribute classes possess constructors taking a `string s`, but the parameter is never used inside the constructor body. The `_assemblyName` or `_img` fields are always populated using hardcoded `AssemblyNames.Navigation` lookups.
|
|
* **Side Effects in Property Getters:** The `AssemblyImage` property getter in `NavigationPropertiesImageAttribute` has a side effect: it assigns the private field `_img` before returning it (`_img = ...; return _img;`). This is non-standard property behavior and could lead to unnecessary object creation if the property is accessed frequently.
|
|
* **Mixed Container Usage:** The module uses `IUnityContainer` (passed via constructor) to register types inside `Initialize`, but the `RegisterTypes` method receives an `IContainerRegistry`. The code bridges this by ignoring the `IContainerRegistry` parameter and using the stored `_unityContainer` reference directly. |