6.2 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-16T04:48:16.508256+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 7a5beb8ec708c422 |
HamburgerMenu
Documentation: HamburgerMenuModule
1. Purpose
The HamburgerMenuModule is a Prism module responsible for registering the view and view model for the application’s 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→HamburgerMenuViewIHamburgerMenuViewModel→HamburgerMenuViewModel
UsesContainerControlledLifetimeManagerto enforce singleton lifetime.
-
void OnInitialized(IContainerProvider containerProvider)
Currently empty. No initialization logic beyondInitialize()is performed here. -
void RegisterTypes(IContainerRegistry containerRegistry)
Delegates toInitialize(). (Note:IContainerRegistryis Prism’s abstraction; however, this implementation ignores it and uses the injectedIUnityContainerdirectly.)
HamburgerMenuModuleNameAttribute class
-
HamburgerMenuModuleNameAttribute()/HamburgerMenuModuleNameAttribute(string s)
Constructor. SetsAssemblyNametoAssemblyNames.HamburgerMenu.ToString()(value inferred fromDTS.Common.Interface.Menu.HamburgerMenunamespace usage). -
string AssemblyName { get; }
Returns"HamburgerMenu"(value ofAssemblyNames.HamburgerMenu.ToString()). -
Type GetAttributeType()
Returnstypeof(TextAttribute). -
string GetAssemblyName()
ReturnsAssemblyName.
HamburgerMenuModuleImageAttribute class
-
HamburgerMenuModuleImageAttribute()/HamburgerMenuModuleImageAttribute(string s)
Constructor. Loads the assembly image viaAssemblyInfo.GetImage("HamburgerMenu"). -
BitmapImage AssemblyImage { get; }
Returns the image loaded byAssemblyInfo.GetImage("HamburgerMenu"). -
string AssemblyName { get; }
Returns"HamburgerMenu". -
string AssemblyGroup { get; }
Returns"Prepare"(value ofeAssemblyGroups.Prepare.ToString()). -
eAssemblyRegion AssemblyRegion { get; }
ReturnseAssemblyRegion.HamburgerMenuRegion. -
Type GetAttributeType()
Returnstypeof(ImageAttribute). -
BitmapImage GetAssemblyImage()
ReturnsAssemblyImage. -
string GetAssemblyName()
ReturnsAssemblyName. -
string GetAssemblyGroup()
ReturnsAssemblyGroup. -
eAssemblyRegion GetAssemblyRegion()
ReturnsAssemblyRegion.
3. Invariants
- The module must be loaded after
DTS.CommonandHamburgerMenuassemblies are available (since it referencesAssemblyNames.HamburgerMenu,AssemblyInfo,eAssemblyGroups, andeAssemblyRegionfrom those). IHamburgerMenuViewandIHamburgerMenuViewModelare registered as singleton instances; multiple resolutions return the same instance.- The
AssemblyNameexposed via attributes is strictly"HamburgerMenu". - The
AssemblyGroupis fixed to"Prepare". - The
AssemblyRegionis fixed toeAssemblyRegion.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 application’s shell (e.g.,
MainWindow.xamlor a region manager) that resolvesIHamburgerMenuViewor uses the module’s metadata (via attributes) to display the hamburger menu component in the UI. - Any module or service that needs to inject
IHamburgerMenuVieworIHamburgerMenuViewModel.
5. Gotchas
RegisterTypesignoresIContainerRegistry: ThoughRegisterTypesreceives aIContainerRegistry, it callsInitialize(), which uses the injectedIUnityContainer. This tightly couples the module to Unity and breaks Prism’s container-agnostic design.- Redundant
OnInitializedimplementation: TheOnInitializedmethod is empty and unused; no post-registration logic is performed. - Attribute metadata is static:
AssemblyImage,AssemblyName,AssemblyGroup, andAssemblyRegionare computed once per attribute instance (in constructor or property getter), but not cached at the assembly level—repeated attribute usage may cause redundantAssemblyInfo.GetImagecalls. - 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/ImageAttributebase classes: Their behavior (e.g., howGetAttributeType()is used) is not inferable from this source. - No validation of
IHamburgerMenuView/IHamburgerMenuViewModelimplementations: Assumes they exist and are compatible with the DI container.
None identified beyond the above.