This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -0,0 +1,120 @@
---
source_files:
- DataPRO/Modules/Menu/HamburgerMenu/HamburgerMenuModule.cs
generated_at: "2026-04-16T04:48:16.508256+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "7a5beb8ec708c422"
---
# HamburgerMenu
## Documentation: HamburgerMenuModule
---
### 1. Purpose
The `HamburgerMenuModule` is a Prism module responsible for registering the view and view model for the applications hamburger menu UI component into the Unity dependency injection container. It enables modular composition of the UI by exposing the hamburger menu as a reusable, injectable component within the Prism-based application shell. The module also contributes metadata—specifically, an assembly name and image—used by the host application (e.g., for display on a main screen summary of available modules). It does not contain business logic but serves as a wiring layer for UI composition.
---
### 2. Public Interface
#### `HamburgerMenuModule` class
- **`HamburgerMenuModule(IUnityContainer unityContainer)`**
Constructor. Accepts a Unity container via dependency injection and stores it for later use in type registration.
- **`void Initialize()`**
Registers two types as singletons in the Unity container:
- `IHamburgerMenuView``HamburgerMenuView`
- `IHamburgerMenuViewModel``HamburgerMenuViewModel`
Uses `ContainerControlledLifetimeManager` to enforce singleton lifetime.
- **`void OnInitialized(IContainerProvider containerProvider)`**
Currently empty. No initialization logic beyond `Initialize()` is performed here.
- **`void RegisterTypes(IContainerRegistry containerRegistry)`**
Delegates to `Initialize()`. (Note: `IContainerRegistry` is Prisms abstraction; however, this implementation ignores it and uses the injected `IUnityContainer` directly.)
#### `HamburgerMenuModuleNameAttribute` class
- **`HamburgerMenuModuleNameAttribute()` / `HamburgerMenuModuleNameAttribute(string s)`**
Constructor. Sets `AssemblyName` to `AssemblyNames.HamburgerMenu.ToString()` (value inferred from `DTS.Common.Interface.Menu.HamburgerMenu` namespace usage).
- **`string AssemblyName { get; }`**
Returns `"HamburgerMenu"` (value of `AssemblyNames.HamburgerMenu.ToString()`).
- **`Type GetAttributeType()`**
Returns `typeof(TextAttribute)`.
- **`string GetAssemblyName()`**
Returns `AssemblyName`.
#### `HamburgerMenuModuleImageAttribute` class
- **`HamburgerMenuModuleImageAttribute()` / `HamburgerMenuModuleImageAttribute(string s)`**
Constructor. Loads the assembly image via `AssemblyInfo.GetImage("HamburgerMenu")`.
- **`BitmapImage AssemblyImage { get; }`**
Returns the image loaded by `AssemblyInfo.GetImage("HamburgerMenu")`.
- **`string AssemblyName { get; }`**
Returns `"HamburgerMenu"`.
- **`string AssemblyGroup { get; }`**
Returns `"Prepare"` (value of `eAssemblyGroups.Prepare.ToString()`).
- **`eAssemblyRegion AssemblyRegion { get; }`**
Returns `eAssemblyRegion.HamburgerMenuRegion`.
- **`Type GetAttributeType()`**
Returns `typeof(ImageAttribute)`.
- **`BitmapImage GetAssemblyImage()`**
Returns `AssemblyImage`.
- **`string GetAssemblyName()`**
Returns `AssemblyName`.
- **`string GetAssemblyGroup()`**
Returns `AssemblyGroup`.
- **`eAssemblyRegion GetAssemblyRegion()`**
Returns `AssemblyRegion`.
---
### 3. Invariants
- The module **must** be loaded after `DTS.Common` and `HamburgerMenu` assemblies are available (since it references `AssemblyNames.HamburgerMenu`, `AssemblyInfo`, `eAssemblyGroups`, and `eAssemblyRegion` from those).
- `IHamburgerMenuView` and `IHamburgerMenuViewModel` are registered as **singleton** instances; multiple resolutions return the same instance.
- The `AssemblyName` exposed via attributes is strictly `"HamburgerMenu"`.
- The `AssemblyGroup` is fixed to `"Prepare"`.
- The `AssemblyRegion` is fixed to `eAssemblyRegion.HamburgerMenuRegion`.
- The image is loaded once per attribute instance (via `AssemblyInfo.GetImage`) and cached in `_img`.
---
### 4. Dependencies
#### This module depends on:
- **Prism.Modularity** (`IModule`, `IContainerRegistry`, `IContainerProvider`)
- **Unity** (`IUnityContainer`, `Unity.Lifetime.ContainerControlledLifetimeManager`)
- **System.ComponentModel.Composition** (`[Export]`, `[Module]`)
- **System.Windows.Media.Imaging** (`BitmapImage`)
- **DTS.Common** (specifically `AssemblyNames`, `AssemblyInfo`, `eAssemblyGroups`, `eAssemblyRegion`)
- **DTS.Common.Interface.Menu.HamburgerMenu** (specifically `IHamburgerMenuView`, `IHamburgerMenuViewModel`)
- **Prism.Ioc** (`IContainerRegistry`, `IContainerProvider`)
#### This module is depended upon by:
- The host applications shell (e.g., `MainWindow.xaml` or a region manager) that resolves `IHamburgerMenuView` or uses the modules metadata (via attributes) to display the hamburger menu component in the UI.
- Any module or service that needs to inject `IHamburgerMenuView` or `IHamburgerMenuViewModel`.
---
### 5. Gotchas
- **`RegisterTypes` ignores `IContainerRegistry`**: Though `RegisterTypes` receives a `IContainerRegistry`, it calls `Initialize()`, which uses the injected `IUnityContainer`. This tightly couples the module to Unity and breaks Prisms container-agnostic design.
- **Redundant `OnInitialized` implementation**: The `OnInitialized` method is empty and unused; no post-registration logic is performed.
- **Attribute metadata is static**: `AssemblyImage`, `AssemblyName`, `AssemblyGroup`, and `AssemblyRegion` are computed once per attribute instance (in constructor or property getter), but not cached at the assembly level—repeated attribute usage may cause redundant `AssemblyInfo.GetImage` calls.
- **No error handling for image loading**: If `AssemblyInfo.GetImage("HamburgerMenu")` fails (e.g., missing resource), the exception propagates during attribute instantiation (e.g., at assembly load time), potentially breaking module discovery.
- **Missing documentation for `TextAttribute`/`ImageAttribute` base classes**: Their behavior (e.g., how `GetAttributeType()` is used) is not inferable from this source.
- **No validation of `IHamburgerMenuView`/`IHamburgerMenuViewModel` implementations**: Assumes they exist and are compatible with the DI container.
None identified beyond the above.

View File

@@ -0,0 +1,62 @@
---
source_files:
- DataPRO/Modules/Menu/HamburgerMenu/Model/MenuCommand.cs
generated_at: "2026-04-16T04:48:40.108913+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "d733624401ce5030"
---
# Model
### 1. **Purpose**
`MenuCommand` is a concrete implementation of `ICommand` used to wrap menu item selections in the Hamburger Menu module. It serves as a lightweight command handler that, when executed, notifies a registered callback (`MenuItemPressedDelegate`) with the menu items unique identifier (`Id`). Its purpose is to decouple UI menu interactions from business logic by translating WPF command execution into a domain-specific callback, enabling loose coupling between the menu UI and the rest of the system.
---
### 2. **Public Interface**
- **`MenuCommand(string id, MenuItemPressedDelegate menuItemPressed)`**
Constructor. Initializes the command with a unique `id` (string) and a delegate (`MenuItemPressedDelegate`) to invoke on execution.
- *Parameters*:
- `id`: A non-null string identifying the menu item.
- `menuItemPressed`: A delegate of type `MenuItemPressedDelegate` (defined in `DTS.Common.Interface.Menu.HamburgerMenu`) to be invoked with `id` when the command executes.
- **`bool CanExecute(object parameter)`**
Always returns `true`. Implements `ICommand.CanExecute`. The command is always executable regardless of the `parameter` value.
- **`void Execute(object parameter)`**
Invokes the `MenuItemPressed` delegate with the stored `Id`. Implements `ICommand.Execute`. The `parameter` is ignored.
- **`event EventHandler CanExecuteChanged`**
Implements `ICommand.CanExecuteChanged`. Declared but *never raised* — consumers should not rely on this event for change notifications.
---
### 3. **Invariants**
- `Id` is immutable after construction (declared `readonly`).
- `MenuItemPressed` delegate is non-null at construction (no null-check is performed; passing `null` will cause a `NullReferenceException` on `Execute`).
- `CanExecute` always returns `true`; no runtime conditions affect executability.
- `CanExecuteChanged` is declared but *never raised* — no external changes to `CanExecute` status are ever signaled.
- `Execute` ignores its `parameter` argument entirely.
---
### 4. **Dependencies**
- **Imports/References**:
- `DTS.Common.Interface.Menu.HamburgerMenu` — Provides the `MenuItemPressedDelegate` type (not defined in this file; assumed to be a delegate type in the referenced namespace).
- `System` and `System.Windows.Input` — For `EventHandler`, `ICommand`, and WPF command infrastructure.
- **Consumers**:
- Presumably instantiated by UI layer code (e.g., in a view model or menu builder) that maps menu items to `MenuCommand` instances.
- Depends on external code to supply the `MenuItemPressedDelegate` implementation (not visible in this file).
---
### 5. **Gotchas**
- **`CanExecuteChanged` is never raised** — This violates typical `ICommand` conventions (e.g., WPF command bindings may not update UI state if they rely on this event). If command executability *should* change dynamically, this implementation is incomplete.
- **No null-safety**: Passing `null` for `menuItemPressed` in the constructor will cause a `NullReferenceException` at `Execute` time.
- **`parameter` is unused** — `Execute` ignores its argument, which may cause issues if consumers expect parameter-based logic (e.g., passing context via `parameter`).
- **No validation of `id`** — No checks for `null` or empty `id`; while not explicitly causing failure, this may lead to ambiguous menu item identification downstream.
- **No thread-safety guarantees** — `CanExecuteChanged` event and delegate invocation are not synchronized.
None identified beyond the above.

View File

@@ -0,0 +1,61 @@
---
source_files:
- DataPRO/Modules/Menu/HamburgerMenu/Properties/Settings.Designer.cs
- DataPRO/Modules/Menu/HamburgerMenu/Properties/AssemblyInfo.cs
generated_at: "2026-04-16T04:48:35.411211+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "f4f04049fd0465b0"
---
# Properties
## Documentation: HamburgerMenu.Properties.Settings
---
### 1. Purpose
This module provides strongly-typed application settings infrastructure for the `HamburgerMenu` module via the `Settings` class, which inherits from `System.Configuration.ApplicationSettingsBase`. It enables centralized, type-safe access to user- or application-scoped configuration values (though no settings are currently defined in the generated file). The module exists solely to support configuration management for the HamburgerMenu UI component and is auto-generated by Visual Studios settings designer—meaning manual edits are discouraged and will be overwritten on regeneration.
---
### 2. Public Interface
#### `HamburgerMenu.Properties.Settings.Default`
- **Type**: `static property`
- **Signature**: `public static Settings Default { get; }`
- **Behavior**: Returns the singleton instance of the `Settings` class, synchronized for thread safety (via `ApplicationSettingsBase.Synchronized`). This is the canonical entry point for accessing settings values.
- **Note**: As the class is auto-generated and contains no explicit settings properties in the provided source, no user-defined settings (e.g., `public string SomeSetting { get; set; }`) are exposed here. Any settings would appear as instance properties on the `Settings` class in the full generated file.
---
### 3. Invariants
- The `Settings` class is **sealed** and **partial**, with thread-safe singleton access enforced via `Synchronized`.
- The `defaultInstance` field is initialized once during type initialization and never reassigned.
- The class inherits from `ApplicationSettingsBase`, which enforces standard .NET settings semantics (e.g., per-user Roaming/Local scope, automatic persistence via config files).
- No validation or custom invariants are defined in the provided source—only those implied by `ApplicationSettingsBase`.
---
### 4. Dependencies
#### Dependencies *of* this module:
- `System.Configuration` (for `ApplicationSettingsBase`)
- `System.Runtime.CompilerServices` (for `CompilerGeneratedAttribute`)
- `System.CodeDom.Compiler` (for `GeneratedCodeAttribute`)
- `System.Runtime.InteropServices` (via `AssemblyInfo.cs`, for COM interop attributes)
#### Dependencies *on* this module:
- Other modules in the `HamburgerMenu` assembly (e.g., UI components) may consume `Settings.Default` to read/write configuration values.
- The `HamburgerMenu` assembly itself (as defined by `AssemblyInfo.cs`) is the sole consumer context—no external dependencies are declared in this module.
---
### 5. Gotchas
- **Auto-generated**: The file header explicitly warns that manual changes will be lost upon regeneration. Do not modify this file directly.
- **No settings defined**: The provided source contains only the boilerplate `Settings` class skeleton. No actual settings properties (e.g., `public bool ShowMenuIcons { get; set; }`) are present—settings must be defined in the projects `.settings` designer file (`.Designer.cs` is regenerated from `.settings`).
- **Thread-safety overhead**: `Synchronized()` wraps the instance in a `LocalFileSettingsProvider`-compatible proxy, but this adds minimal overhead and is standard for `ApplicationSettingsBase`.
- **Versioning**: Assembly version is fixed at `1.0.0.0` (both `AssemblyVersion` and `AssemblyFileVersion`), which may complicate deployment or rollback if settings schema evolves.
- **COM visibility**: `ComVisible(false)` is set—this is appropriate for a .NET UI module but could cause issues if COM consumers expect settings access (unlikely).
None identified beyond the above.

View File

@@ -0,0 +1,54 @@
---
source_files:
- DataPRO/Modules/Menu/HamburgerMenu/Resources/TranslateExtension.cs
- DataPRO/Modules/Menu/HamburgerMenu/Resources/StringResources.Designer.cs
generated_at: "2026-04-16T04:48:26.109962+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "846fd5844632234a"
---
# Resources
## Documentation: `TranslateExtension` Class
### 1. Purpose
The `TranslateExtension` class is a WPF `MarkupExtension` that enables declarative localization of UI strings in XAML. It resolves a given resource key at runtime by querying the `StringResources` strongly-typed resource class and returns the corresponding localized string. If the key is missing or the lookup fails, it returns a placeholder string to make missing translations visually obvious during development. This module exists to support multi-language UIs in the HamburgerMenu module without requiring code-behind for simple string bindings.
### 2. Public Interface
- **`TranslateExtension(string key)`**
Constructor. Accepts a non-null resource key string used to look up a localized value.
- *Parameter*: `key` (`string`) The resource key (e.g., `"Table_NA"`). Must match a key in the `StringResources.resx` file.
- **`override object ProvideValue(IServiceProvider serviceProvider)`**
Implements `MarkupExtension.ProvideValue`. Performs the resource lookup and returns the localized string or a placeholder.
- *Behavior*:
- If `_key` is `null` or empty → returns `"#stringnotfound#"`.
- Else → attempts `StringResources.ResourceManager.GetString(_key)`.
- If found → returns the string.
- If not found (`null`) → returns `"#stringnotfound# " + _key` (e.g., `"#stringnotfound# MyKey"`).
### 3. Invariants
- `_key` is immutable after construction (stored in a `readonly` field).
- The returned value is always a `string` (per `[MarkupExtensionReturnType(typeof(string))]`).
- Missing keys are *never* silently ignored; they always produce a visible placeholder string.
- Resource lookup uses the current UI culture (`CultureInfo`) set on `StringResources.Culture`.
### 4. Dependencies
- **Depends on**:
- `System.Windows.Markup.MarkupExtension` (WPF framework)
- `HamburgerMenu.Resources.StringResources` (strongly-typed resource class)
- `System.Resources.ResourceManager` (via `StringResources.ResourceManager`)
- **Used by**:
- XAML files in the `HamburgerMenu` module (e.g., `<TextBlock Text="{local:Translate Table_NA}" />`).
- No other C# code appears to depend on this class directly (it is XAML-only).
### 5. Gotchas
- **Hardcoded placeholder**: The `"#stringnotfound#"` prefix is hardcoded; changing it requires modifying this class.
- **No fallback chain**: If a key is missing, no secondary key or default value is attempted—only the placeholder is returned.
- **No compile-time key validation**: Typos in XAML (e.g., `{local:Translate Tabl_NA}`) will only surface at runtime as `"#stringnotfound# Tabl_NA"`.
- **Culture dependency**: Localization behavior relies on `StringResources.Culture` being set appropriately (e.g., via `Thread.CurrentThread.CurrentUICulture`). If unset, the default culture is used.
- **Auto-generated resource class**: `StringResources.Designer.cs` is auto-generated; edits will be overwritten. Resource keys must be managed via `.resx` files.
- **No async/safe fallback**: `GetString()` is synchronous and may throw if the underlying resource stream is corrupted (though this is rare).
None identified beyond the above.

View File

@@ -0,0 +1,63 @@
---
source_files:
- DataPRO/Modules/Menu/HamburgerMenu/View/HamburgerMenuView.xaml.cs
generated_at: "2026-04-16T04:48:46.494653+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "2a2ccee5a7defaef"
---
# View
### **1. Purpose**
This module implements the WPF view (`HamburgerMenuView`) for a hamburger menu UI component in a desktop application. It serves as the visual layer for triggering a context menu via a hamburger button click, implementing the `IHamburgerMenuView` interface. The class coordinates with its associated view model (`IHamburgerMenuViewModel`) to display context-sensitive menu options when the user interacts with the hamburger icon, but otherwise contains no active logic beyond that single interaction.
---
### **2. Public Interface**
The class is `public partial`, but only one public constructor is present. No public methods or properties are defined in this file.
- **`HamburgerMenuView()`**
*Signature:* `public HamburgerMenuView()`
*Behavior:* Initializes the WPF component by calling `InitializeComponent()` (which binds to `HamburgerMenuView.xaml`). No additional logic is performed.
No other public members (methods, properties, events) are declared or implemented in this source file.
---
### **3. Invariants**
The following invariants are *implied* by the active code (`Hamburger_Click` handler), though not explicitly enforced:
- `DataContext` **must** be an instance of `IHamburgerMenuViewModel` at the time the hamburger button is clicked; otherwise, the cast `(IHamburgerMenuViewModel)DataContext` will throw an `InvalidCastException`.
- The `IHamburgerMenuViewModel.GetContextMenu()` method **must** return a non-null `ContextMenu` object; otherwise, setting `cm.PlacementTarget` or `cm.IsOpen` will throw a `NullReferenceException`.
- The `sender` parameter in `Hamburger_Click` **must** be a `Button` (or castable to `Button`) for `cm.PlacementTarget = sender as Button` to assign a valid target; if `sender` is not a `Button`, `PlacementTarget` will be `null`, potentially causing unexpected menu placement.
No other invariants (e.g., state ordering, lifecycle constraints) are specified or inferable from this file alone.
---
### **4. Dependencies**
**Imports/References (from source):**
- `DTS.Common.Interface.Menu.HamburgerMenu` — Provides the `IHamburgerMenuView` and `IHamburgerMenuViewModel` interfaces.
- `System.Windows.Controls` — Used for WPF controls (e.g., `Button`, `ContextMenu`).
**External contracts (inferred):**
- Requires a view model implementing `IHamburgerMenuViewModel` to be assigned to `DataContext`.
- The `IHamburgerMenuViewModel` interface must define at least:
- `ContextMenu GetContextMenu()`
- The `IHamburgerMenuView` interface (from `DTS.Common.Interface.Menu.HamburgerMenu`) is implemented by this class, but its contract is not visible in this file.
**Dependents (inferred):**
- This view is likely consumed by a DI container or XAML-based navigation system that binds `HamburgerMenuView` to its corresponding `IHamburgerMenuViewModel`.
- No direct dependents are visible in this file.
---
### **5. Gotchas**
- **Unsafe cast on `DataContext`**: The `Hamburger_Click` handler performs an unguarded cast to `IHamburgerMenuViewModel`. If `DataContext` is not set or is of the wrong type, a runtime exception will occur.
- **`sender as Button` may be `null`**: If the click event originates from a non-`Button` control (e.g., a `Grid` with `Button` as child), `PlacementTarget` will be `null`, possibly causing the context menu to appear at an incorrect location or fail silently.
- **Commented-out legacy code**: The file contains multiple large blocks of commented-out event handlers (e.g., `GridViewColumnHeaderSearchable_OnSearch`, `MouseDoubleClick`, `TreeviewButton_Click`). These suggest historical functionality related to hardware lists and tree views, but are currently inactive and could mislead developers about current capabilities.
- **No public API surface**: Despite being a WPF view class, this module exposes *no* public methods or properties beyond the constructor, making its role purely passive and entirely dependent on data binding and XAML wiring.
- **Missing null checks**: No validation is performed on `vm.GetContextMenu()` result before use — a common source of `NullReferenceException` if the view model is misconfigured.
None identified beyond the above.

View File

@@ -0,0 +1,136 @@
---
source_files:
- DataPRO/Modules/Menu/HamburgerMenu/ViewModel/HamburgerMenuViewModel.cs
generated_at: "2026-04-16T04:48:30.206063+00:00"
model: "Qwen/Qwen3-Coder-Next-FP8"
schema_version: 1
sha256: "462d2b26bf58cd93"
---
# ViewModel
## Documentation: `HamburgerMenuViewModel`
---
### 1. **Purpose**
The `HamburgerMenuViewModel` class serves as the MVVM-compliant view model for the applications hamburger menu UI component. It manages the state and behavior of the menu—including item list, enabled/disabled status, busy state, and context menu construction—while acting as a bridge between the view (`IHamburgerMenuView`) and the broader system via Prisms event aggregation and Unity dependency injection. It subscribes to system-wide events (e.g., test lifecycle, busy indicators, notifications) to dynamically update its state and exposes interaction requests for modal UI (notifications, confirmations). It is a shared singleton (per container) responsible for rendering a context menu populated from a string array and raising a delegate when menu items are selected.
---
### 2. **Public Interface**
- **`IHamburgerMenuView View { get; set; }`**
Reference to the associated view; set during construction and used to bind `DataContext`.
- **`InteractionRequest<Notification> NotificationRequest { get; }`**
Prism interaction request used to trigger notification popups (e.g., informational messages).
- **`InteractionRequest<Confirmation> ConfirmationRequest { get; }`**
Prism interaction request used to trigger confirmation dialogs (e.g., yes/no prompts).
- **`event PropertyChangedEventHandler PropertyChanged;`**
Standard `INotifyPropertyChanged` implementation for data binding.
- **`void OnPropertyChanged(string propertyName);`**
Raises the `PropertyChanged` event for the specified property.
- **`ContextMenu GetContextMenu();`**
Returns the lazily-built `ContextMenu` instance. Builds it on first call if not already constructed. Thread-safe via `lock(MyLock)`.
- **`void SetMenuItems(string[] items);`**
Sets the list of menu item labels and immediately rebuilds the context menu.
- **`void ClearMenuItems();`**
Clears the internal `_menuItems` array and triggers a rebuild (resulting in an empty menu).
- **`void EnableMenu(bool enable);`**
Sets `IsEnabled` to `enable`, updating the UI state.
- **`void Unset();`**
Currently empty; no-op.
- **`void OnSetActive();`**
Currently empty; no-op.
- **`void Cleanup();`**
Currently empty; no-op.
- **`Task CleanupAsync();`**
Returns `Task.CompletedTask`; no-op.
- **`void Initialize();`**
Overload variants (`Initialize()`, `Initialize(object)`, `Initialize(object, object)`) are present but all currently no-op.
- **`Task InitializeAsync();`**
Overload variants (`InitializeAsync()`, `InitializeAsync(object)`) are present but all return `Task.CompletedTask`; no-op.
- **`void Activated();`**
Currently empty; no-op.
- **`bool IsEnabled { get; private set; }`**
Indicates whether the menu is enabled. Default `true`. Updated via `EnableMenu()`, `OnTestEvent()`, or internal logic.
- **`bool IsBusy { get; set; }`**
Indicates whether the menu is in a busy state (e.g., during test execution). Bound to `BusyIndicatorChangeNotification` event.
- **`bool IsMenuIncluded { get; set; }`**
Indicates whether the hamburger menu is included in the UI. Not used internally—likely for view-level visibility binding.
- **`bool IsNavigationIncluded { get; set; }`**
Indicates whether navigation controls are included in the UI. Not used internally—likely for view-level visibility binding.
- **`MenuItemPressedDelegate MenuItemPressed { get; set; }`**
Delegate invoked when a menu item is pressed. Signature: `void Delegate(string id)`. The `id` passed is the `Header` of the selected `MenuItem`.
---
### 3. **Invariants**
- `View.DataContext` is always set to `this` in the constructor.
- `_contextMenu` is lazily initialized on first call to `GetContextMenu()` and rebuilt only when `_menuItems` changes (via `SetMenuItems()` or `ClearMenuItems()`).
- `_menuItems` is never `null`; it is initialized to `new string[0]` and cleared to `new string[0]`.
- `IsEnabled` defaults to `true`.
- `IsBusy` is updated synchronously on the publisher thread (via `ThreadOption.PublisherThread`) in response to `BusyIndicatorChangeNotification`.
- Thread safety for context menu construction is ensured via `lock(MyLock)` in `GetContextMenu()` and `BuildContextMenu()`.
- Automation IDs are set on the `ContextMenu` (`"HamburgerMenu"`) and each `MenuItem` (`"MenuItem_{ItemName}"`, with spaces removed).
- `MenuItemPressed` is invoked with the `Header` string of the selected `MenuItem`.
---
### 4. **Dependencies**
**Imports/References (from source):**
- `System.ComponentModel`, `System.ComponentModel.Composition` (MEF)
- `Prism.Events`, `Prism.Regions` (Prism framework)
- `Unity` (Unity DI container)
- `DTS.Common.Events` (custom event types: `RaiseNotification`, `BusyIndicatorChangeNotification`, `TestEvent`)
- `DTS.Common.Interface.Menu.HamburgerMenu` (interface `IHamburgerMenuViewModel`)
- `DTS.Common.Interactivity` (interaction request types: `Notification`, `Confirmation`)
- `System.Windows.Controls`, `System.Windows.Automation`
**Depends on:**
- `IHamburgerMenuView` (view interface)
- `IRegionManager`, `IEventAggregator`, `IUnityContainer` (Prism/Unity infrastructure)
- `TestEvent`, `BusyIndicatorChangeNotification`, `RaiseNotification` (custom events via `IEventAggregator`)
**Used by:**
- Likely consumed by `IHamburgerMenuView` (WPF view) via data binding.
- Other modules may publish `TestEvent`, `BusyIndicatorChangeNotification`, or `RaiseNotification` to control its behavior.
---
### 5. **Gotchas**
- **Empty lifecycle methods**: `Initialize*`, `Cleanup*`, `Unset`, `OnSetActive`, and `Activated` are all no-ops. If lifecycle management is expected, this may be incomplete or deferred to the view.
- **`MenuItemPressed` is a delegate, not an event**: It is declared as `public MenuItemPressedDelegate MenuItemPressed { get; set; }`, meaning it can be overwritten and is not thread-safe for multicast subscriptions. Callers must ensure safe assignment.
- **`IsDirty` property exists but is never set**: Declared as `public bool IsDirty { get; private set; }`, but never assigned—likely unused or incomplete.
- **`IsMenuIncluded` and `IsNavigationIncluded` are never set internally**: Only exposed as properties; their values must be set externally (e.g., by view or another VM), but no logic uses them.
- **`AutomationProperties.AutomationIdProperty` is hardcoded**: Menu item IDs are derived by removing spaces from the header (`item.Replace(" ", "")`). This may cause collisions if headers differ only by whitespace (e.g., `"Run Test"` vs `"RunTest"` both become `"MenuItem_RunTest"`).
- **`GetContextMenu()` returns the same instance after first build**: Repeated calls return the cached `_contextMenu`. If `_menuItems` changes but `GetContextMenu()` is called before `SetMenuItems()`/`ClearMenuItems()` triggers `BuildContextMenu()`, stale items may be returned.
- **`OnTestEvent()` toggles `IsEnabled` only on `TestStarted`/`TestEnded`**: If `TestEventArg.Status` is anything else (e.g., `TestRunning`), `IsEnabled` remains unchanged—assumes only two statuses.
- **Thread safety**: Only `GetContextMenu()` and `BuildContextMenu()` are thread-safe. Other property setters (e.g., `IsBusy`) assume caller handles thread affinity (though `IsBusy` setter uses `OnPropertyChanged`, which may marshal to UI thread depending on binding context—*not guaranteed*).
- **No unsubscription from events**: The constructor subscribes to events but there is no `IDisposable` implementation or `Unsubscribe()` call—potential memory leak if the VM outlives its intended lifetime.
> *None of the above are necessarily bugs, but they are non-obvious and require awareness during maintenance or extension.*