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

6.5 KiB
Raw Permalink Blame History

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DataPRO/Modules/Channels/ChannelCodes/ChannelCodesModule.cs
2026-04-16T04:55:41.104321+00:00 Qwen/Qwen3-Coder-Next-FP8 1 08f6598fbadc11d8

ChannelCodes

1. Purpose

The ChannelCodesModule is a Prism-based modular component responsible for registering the UI views and view models associated with channel code management within the application. It integrates into the modular architecture by implementing the IModule interface and registering its core components—ChannelCodesListViewModel and ChannelCodesListView—as singleton services in the Unity dependency injection container during module initialization. Additionally, it contributes metadata (name, image, group, and region) to the host applications UI (e.g., main screen) via custom assembly-level attributes (ChannelCodesModuleNameAttribute and ChannelCodesModuleImageAttribute), enabling dynamic discovery and presentation of the module.


2. Public Interface

Classes & Interfaces

  • ChannelCodesModule : IModule
    Namespace: ChannelCodes
    Purpose: Prism module entry point for channel codes functionality.
    • ChannelCodesModule(IUnityContainer unityContainer)
      Constructor. Accepts and stores a Unity container reference for later registration of types.
    • void Initialize()
      Registers two types as singletons in the Unity container:
      • IChannelCodesListViewModelChannelCodesListViewModel
      • IChannelCodesListViewChannelCodesListView
        Called internally by RegisterTypes() (via Prisms module lifecycle).
    • void OnInitialized(IContainerProvider containerProvider)
      Currently empty; no logic implemented.
    • void RegisterTypes(IContainerRegistry containerRegistry)
      Delegates to Initialize() (despite using Prisms IContainerRegistry, it uses the Unity-specific _unityContainer internally).

Assembly-Level Attributes

  • [ChannelCodesModuleName]
    Applied to assembly.

    • ChannelCodesModuleNameAttribute : TextAttribute
      • Constructor ChannelCodesModuleNameAttribute(string s)
        Sets AssemblyName to AssemblyNames.ChannelCodes.ToString().
      • override string AssemblyName { get; }
        Returns "ChannelCodes" (value of AssemblyNames.ChannelCodes.ToString()).
      • override Type GetAttributeType()
        Returns typeof(TextAttribute).
      • override string GetAssemblyName()
        Returns AssemblyName.
  • [ChannelCodesModuleImage]
    Applied to assembly.

    • ChannelCodesModuleImageAttribute : ImageAttribute
      • Constructor ChannelCodesModuleImageAttribute(string s)
        Loads image via AssemblyInfo.GetImage("ChannelCodes").
      • override BitmapImage AssemblyImage { get; }
        Returns the image loaded from AssemblyInfo.GetImage("ChannelCodes").
      • override BitmapImage GetAssemblyImage()
        Returns AssemblyImage.
      • override string AssemblyName { get; }
        Returns "ChannelCodes".
      • override string GetAssemblyName()
        Returns AssemblyName.
      • override string AssemblyGroup { get; }
        Returns "Prepare" (value of eAssemblyGroups.Prepare.ToString()).
      • override string GetAssemblyGroup()
        Returns AssemblyGroup.
      • override eAssemblyRegion AssemblyRegion { get; }
        Returns eAssemblyRegion.ChannelCodesRegion.
      • override eAssemblyRegion GetAssemblyRegion()
        Returns AssemblyRegion.
      • override Type GetAttributeType()
        Returns typeof(ImageAttribute).

3. Invariants

  • The module must be loaded after the Unity container and AssemblyInfo service are available (since AssemblyInfo.GetImage() is called during attribute instantiation).
  • AssemblyNames.ChannelCodes, eAssemblyGroups.Prepare, and eAssemblyRegion.ChannelCodesRegion must be defined and valid in the referenced DTS.Common assembly; otherwise, runtime errors will occur during attribute initialization.
  • The Initialize() method assumes _unityContainer is non-null and properly configured; no null-check is performed.
  • The RegisterTypes() methods use of IContainerRegistry is misleading—it ignores the containerRegistry parameter and operates solely on the injected _unityContainer. This may cause confusion or failure if Prisms IContainerRegistry is expected to be used.

4. Dependencies

Imports / External Dependencies

  • Prism.Modularity (IModule, IContainerProvider, IContainerRegistry)
  • Unity (IUnityContainer)
  • DTS.Common (specifically AssemblyNames, AssemblyInfo, eAssemblyGroups, eAssemblyRegion, TextAttribute, ImageAttribute)
  • System.Windows.Media.Imaging (for BitmapImage)
  • ChannelCodes namespace (contains IChannelCodesListViewModel, IChannelCodesListView, ChannelCodesListViewModel, ChannelCodesListView—not shown in this file but referenced).

Depended Upon By

  • The host applications module loading infrastructure (Prism + Unity) to discover and load this module.
  • UI components (e.g., main screen) that consume ChannelCodesModuleNameAttribute and ChannelCodesModuleImageAttribute to render module metadata.

5. Gotchas

  • Misleading RegisterTypes implementation: Despite implementing Prisms RegisterTypes(IContainerRegistry), the method ignores containerRegistry and uses the Unity-specific _unityContainer. This breaks Prisms intended container abstraction and tightly couples the module to Unity.
  • Attribute initialization side effects: ChannelCodesModuleImageAttribute calls AssemblyInfo.GetImage(...) in its constructor and property getters. This may cause exceptions if AssemblyInfo is not yet initialized or the image resource is missing—especially during design-time or in test environments.
  • No validation in Initialize(): Type registrations occur unconditionally. If IChannelCodesListViewModel or IChannelCodesListView are not implemented, registration will fail silently until resolution time (or throw on first use).
  • Redundant/unused constructor parameters: Both attribute constructors accept a string s parameter that is unused (assigned to _name/_img but never read beyond assignment).
  • No documentation for OnInitialized: The empty override suggests incomplete implementation or future extensibility—unclear intent from source alone.