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

7.3 KiB
Raw Permalink Blame History

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DataPRO/Modules/TestSetups/CachedItemsList/CachedItemsListModule.cs
2026-04-16T04:49:30.522340+00:00 Qwen/Qwen3-Coder-Next-FP8 1 9857e307f8488ab7

CachedItemsList

Documentation: CachedItemsListModule


Purpose

The CachedItemsListModule is a Prism-based modular component responsible for registering the view and view model for the Cached Items List UI feature within the applications dependency injection container (Unity). It enables dynamic loading and integration of the CachedItemsList feature as a Prism module, exposing its UI components (CachedItemsListView and CachedItemsListViewModel) as singleton services via interface abstractions (ICachedItemsListView, ICachedItemsListViewModel). The module also contributes metadata (name, image, group, region) to the host applications module discovery and UI assembly system via custom assembly-level attributes.


Public Interface

Class: CachedItemsListModule

  • Namespace: CachedItemsList
  • Inherits: IModule (Prism.Modularity)
  • Attributes: [Export(typeof(IModule))], [Module(ModuleName = "CachedItemsListModule")]
Member Signature Description
Constructor public CachedItemsListModule(IUnityContainer unityContainer) Initializes the module with the Unity container instance via DI. Stores reference for later registration.
Initialize() public void Initialize() Registers the view and view model types as singletons in the Unity container:
ICachedItemsListViewCachedItemsListView
ICachedItemsListViewModelCachedItemsListViewModel
OnInitialized(IContainerProvider containerProvider) public void OnInitialized(IContainerProvider containerProvider) Currently empty. No initialization logic beyond registration.
RegisterTypes(IContainerRegistry containerRegistry) public void RegisterTypes(IContainerRegistry containerRegistry) Delegates to Initialize(). (Note: Uses IContainerRegistry from Prism, but internally calls IUnityContainer-based Initialize(); may indicate legacy or transitional DI usage.)

Attribute: CachedItemsListModuleNameAttribute

  • Namespace: CachedItemsList
  • Inherits: TextAttribute (from DTS.Common.Interface)
  • Usage: [assembly: CachedItemsListModuleName]
Member Signature Description
Constructor public CachedItemsListModuleNameAttribute(string s = null) Initializes with optional parameter (unused).
AssemblyName public override string AssemblyName { get; } Returns "CachedItemsList" (from AssemblyNames.CachedItemsList.ToString()).
GetAttributeType() public override Type GetAttributeType() Returns typeof(TextAttribute).
GetAssemblyName() public override string GetAssemblyName() Returns AssemblyName.

Attribute: CachedItemsListModuleImageAttribute

  • Namespace: CachedItemsList
  • Inherits: ImageAttribute (from DTS.Common.Interface)
  • Usage: [assembly: CachedItemsListModuleImageAttribute]
Member Signature Description
Constructor public CachedItemsListModuleImageAttribute(string s = null) Initializes image and name by calling AssemblyInfo.GetImage(...).
AssemblyImage public override BitmapImage AssemblyImage { get; } Returns a BitmapImage loaded via AssemblyInfo.GetImage("CachedItemsList").
AssemblyName public override string AssemblyName { get; } Returns "CachedItemsList".
AssemblyGroup public override string AssemblyGroup { get; } Returns "Prepare" (from eAssemblyGroups.Prepare.ToString()).
AssemblyRegion public override eAssemblyRegion AssemblyRegion { get; } Returns eAssemblyRegion.CachedItemsListRegion.
GetAttributeType() public override Type GetAttributeType() Returns typeof(ImageAttribute).
GetAssemblyImage() / GetAssemblyName() / GetAssemblyGroup() / GetAssemblyRegion() public override ... Delegates to corresponding properties.

Invariants

  • Singleton Registration: Both ICachedItemsListView and ICachedItemsListViewModel are registered as singletons in the Unity container during Initialize(). This implies only one instance of each will exist per application lifetime.
  • Module Name Consistency: The modules registered name ("CachedItemsListModule") and assembly metadata (AssemblyNames.CachedItemsList.ToString()) must match expected values by the host application for correct module loading and UI integration.
  • Region Mapping: The AssemblyRegion is fixed to eAssemblyRegion.CachedItemsListRegion, indicating the module expects to be injected into a region of that name (e.g., via Prisms RegionManager).
  • Group Membership: The module belongs to the "Prepare" group (eAssemblyGroups.Prepare), likely used for UI categorization (e.g., in a module selection screen).

Dependencies

Dependencies of this module

  • Prism.Modularity: Requires IModule interface for Prism module lifecycle.
  • Unity Container: Uses IUnityContainer (via Unity namespace) for type registration.
  • DTS.Common & DTS.Common.Interface: Relies on:
    • AssemblyNames.CachedItemsList enum value.
    • AssemblyInfo.GetImage(...) method for image loading.
    • eAssemblyGroups.Prepare enum value.
    • eAssemblyRegion.CachedItemsListRegion enum value.
    • Base attribute types: TextAttribute, ImageAttribute.
  • WPF: Uses System.Windows.Media.Imaging.BitmapImage (indicating this module targets WPF UI).

Dependencies on this module

  • Host Application: The main application (not shown) must:
    • Discover and load this module via Prism module catalog.
    • Use CachedItemsListRegion for view injection.
    • Rely on AssemblyInfo.GetImage(...) and AssemblyNames for UI rendering of module metadata.

Gotchas

  • DI Container Mismatch: RegisterTypes accepts IContainerRegistry (Prisms abstraction), but internally calls Initialize(), which uses IUnityContainer. This implies the module assumes Unity is the underlying container and may break if used with another DI container (e.g., DryIoc, Autofac) without adapter support.
  • Redundant OnInitialized: The OnInitialized method is empty and unused. If future logic is added here, ensure it does not conflict with Initialize() (which runs earlier).
  • Hardcoded Assembly Name: "CachedItemsList" is hardcoded in multiple places (e.g., AssemblyNames.CachedItemsList.ToString()). Renaming the assembly or enum value requires synchronized updates.
  • Image Loading Side Effects: AssemblyInfo.GetImage(...) is called in the attribute constructor (during assembly load), which may cause runtime failures if the image resource is missing or path is incorrect—failures may occur before module initialization.
  • No View/ViewModel Initialization Logic: The module only registers types; no view initialization (e.g., setting DataContext) occurs here. That responsibility likely resides in the host application or view-level Prism behaviors.

None identified beyond the above.