6.4 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-16T04:52:44.195014+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 281b61d00fb66791 |
SensorsList
Documentation: SensorsListModule
1. Purpose
The SensorsListModule is a Prism module responsible for registering the view and view model types associated with the Sensors List UI component into the Unity dependency injection container. It enables modular composition of the application by exposing the SensorsListView, SensorsListViewModel, SensorsListEditGroupView, and SensorsListEditGroupViewModel as singleton services via their respective interfaces (ISensorsListView, ISensorsListViewModel, etc.). Additionally, the module contributes metadata (name, image, group, and region) to the host application’s module discovery and UI assembly system via assembly-level attributes (SensorsListModuleNameAttribute, SensorsListModuleImageAttribute), allowing the main screen to display and categorize this module.
2. Public Interface
-
SensorsListModuleclasspublic SensorsListModule(IUnityContainer unityContainer)
Constructor. Accepts a Unity container via dependency injection and stores it for later use in type registration.public void Initialize()
Registers four types as singletons in the Unity container:ISensorsListView→SensorsListViewISensorsListViewModel→SensorsListViewModelISensorsListEditGroupView→SensorsListEditGroupViewISensorsListEditGroupViewModel→SensorsListEditGroupViewModel
This method is called byRegisterTypes, and is also invoked directly during module initialization.
public void OnInitialized(IContainerProvider containerProvider)
Currently empty; no logic is executed during Prism’sOnInitializedphase.public void RegisterTypes(IContainerRegistry containerRegistry)
Delegates toInitialize(), which uses the injectedIUnityContainer(notcontainerRegistry). Note:containerRegistryis unused.
-
SensorsListModuleNameAttributeclasspublic override string AssemblyName { get; }
Returns"SensorsList"(fromAssemblyNames.SensorsList.ToString()).public override Type GetAttributeType()
Returnstypeof(TextAttribute).public override string GetAssemblyName()
Returns the value ofAssemblyName.
-
SensorsListModuleImageAttributeclasspublic override BitmapImage AssemblyImage { get; }
Returns the image loaded viaAssemblyInfo.GetImage("SensorsList").public override string AssemblyName { get; }
Returns"SensorsList".public override string AssemblyGroup { get; }
Returns"Prepare"(fromeAssemblyGroups.Prepare.ToString()).public override eAssemblyRegion AssemblyRegion { get; }
ReturnseAssemblyRegion.SensorsListRegion.public override Type GetAttributeType()
Returnstypeof(ImageAttribute).public override BitmapImage GetAssemblyImage()
ReturnsAssemblyImage.public override string GetAssemblyName()
ReturnsAssemblyName.public override string GetAssemblyGroup()
ReturnsAssemblyGroup.public override eAssemblyRegion GetAssemblyRegion()
ReturnsAssemblyRegion.
3. Invariants
- The module must be loaded after the Unity container is available (via Prism’s module loading mechanism).
- The
SensorsListModuleNameAttributeandSensorsListModuleImageAttributemust be applied at the assembly level (enforced via[assembly: ...]directives). - The
AssemblyNames.SensorsListenum value andeAssemblyGroups.Prepare,eAssemblyRegion.SensorsListRegionmust be defined elsewhere (not in this file); their values are assumed constant. - All registered types (
SensorsListView,SensorsListViewModel, etc.) must have parameterless constructors or be resolvable by Unity (no explicit constructor injection is declared for them here). Initialize()is called exactly once per module instance, duringRegisterTypes.
4. Dependencies
Dependencies of this module:
DTS.CommonandDTS.Common.Interface(specificallyAssemblyNames,AssemblyInfo,eAssemblyGroups,eAssemblyRegion)Prism.Modularity(IModule,ModuleAttribute)Prism.Ioc(IContainerProvider,IContainerRegistry)Unity(IUnityContainer)System.Windows.Media.Imaging(forBitmapImage)
Dependencies on this module:
- The host application (or other modules) that consumes the registered views/view models via
ISensorsListView,ISensorsListViewModel, etc. - UI composition logic that relies on
SensorsListModuleImageAttributemetadata to render module icons and groupings in the main screen.
5. Gotchas
- Unused parameter in
RegisterTypes: TheIContainerRegistry containerRegistryparameter is ignored; the method uses the pre-injected_unityContainerinstead. This may cause confusion if Prism’sRegisterTypesis expected to usecontainerRegistry. - Redundant
Initialize()call:Initialize()is invoked both directly in the constructor’s usage path and viaRegisterTypes, but since it’s idempotent (only performs registrations), this is safe. Still, it’s non-standard Prism pattern (typicallyRegisterTypesusescontainerRegistry, andOnInitializedhandles post-registration setup). - No error handling: If
AssemblyInfo.GetImage("SensorsList")fails (e.g., missing image resource), the attribute constructors will throw at assembly load time (not lazily), potentially breaking module discovery. - Attribute constructors perform side effects:
SensorsListModuleImageAttribute’s constructor callsAssemblyInfo.GetImage(...), which may involve I/O or resource loading. This happens at assembly load time, not module initialization time. - No documentation on view/view model lifetimes beyond "singleton": While Unity registration implies singleton, Prism’s
IContainerRegistrytypically usesContainerControlledLifetimeManagerfor singletons — but here theIUnityContaineris used directly, so behavior depends on Unity’s default registration semantics (which are singleton unless overridden). - No usage of
IContainerProviderinOnInitialized: The method is empty, suggesting incomplete implementation or future extensibility.