Files
2026-04-17 14:55:32 -04:00

6.0 KiB
Raw Permalink Blame History

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DataPRO/Modules/Hardware/HardwareList/HardwareListModule.cs
2026-04-16T04:36:26.091510+00:00 Qwen/Qwen3-Coder-Next-FP8 1 253455657d30760d

HardwareList

Documentation: HardwareListModule


1. Purpose

The HardwareListModule is a Prism-based modular component responsible for registering core views and view models related to hardware inventory management within the applications UI framework. It integrates with Unity as the dependency injection container to expose singleton instances of interfaces such as IHardwareListView, ISLICE6TreeView, and IHardwareListViewModel, enabling modular UI composition and decoupled view-model binding. The module also contributes metadata (name, image, group, region) to the host applications module discovery and presentation system via assembly-level attributes.


2. Public Interface

HardwareListModule class

  • Namespace: HardwareList

  • Inherits: IModule (Prism)

  • Constructor:

    public HardwareListModule(IUnityContainer unityContainer)
    

    Injects the Unity container for later type registration.

  • Initialize():

    public void Initialize()
    

    Registers the following view and view model types as transient (note: despite the comment, Unitys RegisterType<TInterface, TImplementation>() defaults to transient unless ContainerControlledLifetimeManager is specified):

    • IHardwareListViewHardwareListView
    • ISLICE6TreeViewSLICE6TreeView
    • IHardwareListOverdueViewHardwareListOverdueView
    • IHardwareListSelectViewHardwareListSelectView
    • IHardwareListViewModelHardwareListViewModel
    • IHardwareListReplaceViewHardwareListReplaceView
  • OnInitialized(IContainerProvider containerProvider):

    public void OnInitialized(IContainerProvider containerProvider)
    

    Empty implementation; no post-initialization logic.

  • RegisterTypes(IContainerRegistry containerRegistry):

    public void RegisterTypes(IContainerRegistry containerRegistry)
    

    Delegates to Initialize(), which uses the injected IUnityContainer (not containerRegistry). Note: This is likely a bug or legacy pattern—containerRegistry is unused.

Assembly-level attributes

  • HardwareListModuleNameAttribute

    • Usage: [assembly: HardwareListModuleName]
    • Purpose: Exposes the modules assembly name (AssemblyNames.HardwareList.ToString()) for runtime identification.
    • Key properties:
      • AssemblyName: Returns "HardwareList" (via AssemblyNames.HardwareList).
      • GetAttributeType(): Returns typeof(TextAttribute).
  • HardwareListModuleImageAttribute

    • Usage: [assembly: HardwareListModuleImageAttribute]
    • Purpose: Supplies UI metadata (image, group, region) for display on the main screens module summary.
    • Key properties:
      • AssemblyImage: Loads image via AssemblyInfo.GetImage("HardwareList").
      • AssemblyGroup: Returns "Prepare" (via eAssemblyGroups.Prepare).
      • AssemblyRegion: Returns eAssemblyRegion.HardwareListRegion.
      • AssemblyName: Returns "HardwareList".

3. Invariants

  • Module registration order: Views/view models are registered during Initialize(); no guarantees about registration order relative to other modules (depends on Prisms module loading sequence).
  • Lifetime management: All registrations use Unitys default transient lifetime (despite the comment claiming "singleton"). No singleton behavior is enforced.
  • Attribute constraints:
    • HardwareListModuleNameAttribute and HardwareListModuleImageAttribute are assembly-level, non-repeatable (AllowMultiple = false).
    • AssemblyRegion must be eAssemblyRegion.HardwareListRegion.
    • AssemblyGroup must be eAssemblyGroups.Prepare.

4. Dependencies

Dependencies of this module:

  • Prism.Modularity: For IModule interface.
  • Unity: For IUnityContainer and IContainerRegistry (though RegisterTypes uses Unity, not the Prism container registry).
  • DTS.Common and DTS.Common.Interface: Specifically:
    • AssemblyNames.HardwareList (enum)
    • AssemblyInfo.GetImage()
    • eAssemblyGroups and eAssemblyRegion enums
  • System.Windows.Media.Imaging: For BitmapImage in HardwareListModuleImageAttribute.

Dependencies on this module:

  • Host application likely depends on HardwareListModule to resolve hardware-related views (e.g., IHardwareListView) via DI.
  • Other modules may depend on interfaces like ISLICE6TreeView or IHardwareListViewModel for composition.

5. Gotchas

  • RegisterTypes ignores containerRegistry: The RegisterTypes method calls Initialize(), which uses the pre-injected _unityContainer. This contradicts Prisms recommended pattern (where RegisterTypes should use containerRegistry) and may cause issues if the module is loaded in a Prism container that does not share Unitys container instance.
  • Misleading comment: The Initialize() methods comment claims registrations are "singleton", but Unitys RegisterType<TInterface, TImplementation>() without a lifetime manager is transient.
  • Attribute duplication: Both HardwareListModuleNameAttribute and HardwareListModuleImageAttribute define AssemblyName identically, but only HardwareListModuleImageAttribute provides UI-relevant metadata.
  • No error handling: AssemblyInfo.GetImage() may fail (e.g., missing image resource), but no fallback or logging is present in the attributes.
  • Unused OnInitialized: The OnInitialized method is empty and unused—potential dead code.
  • Namespace HardwareList: The namespace matches the module name, which may cause confusion with the HardwareList folder path or other similarly named components.

None identified from source alone beyond the above.