Files
DP44/enriched-qwen3-coder-next/DataPRO/Modules/SystemSettings/RealtimeSettings.md
2026-04-17 14:55:32 -04:00

6.1 KiB
Raw Blame History

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DataPRO/Modules/SystemSettings/RealtimeSettings/RealtimeSettingsModule.cs
2026-04-16T04:40:02.624732+00:00 Qwen/Qwen3-Coder-Next-FP8 1 178b0f618bea4bf7

RealtimeSettings

Documentation: RealtimeSettingsModule

1. Purpose

The RealtimeSettingsModule is a Prism module responsible for bootstrapping and registering the view and view model for the Realtime Settings UI component within the application. It integrates with the Unity dependency injection container to expose IRealtimeSettingsView and IRealtimeSettingsViewModel as singleton services, enabling their later resolution and composition into the main UI. Additionally, it provides assembly-level metadata via the RealtimeSettingsImageAttribute, which is used by the host application (e.g., on the main screen) to display the modules name, group, and icon.

2. Public Interface

RealtimeSettingsModule

  • RealtimeSettingsModule(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:
    • IRealtimeSettingsViewRealtimeSettingsView
    • IRealtimeSettingsViewModelRealtimeSettingsViewModel
      This method is called by RegisterTypes, and is expected to be invoked exactly once during module initialization.
  • void OnInitialized(IContainerProvider containerProvider)
    Empty implementation. No post-initialization logic is defined.
  • void RegisterTypes(IContainerRegistry containerRegistry)
    Delegates to Initialize(), performing the same type registrations. Note: Although the parameter is of type IContainerRegistry, the method internally uses the stored _unityContainer (of type IUnityContainer) rather than containerRegistry. This suggests potential inconsistency with Prisms expected pattern.

RealtimeSettingsImageAttribute

  • RealtimeSettingsImageAttribute()
    Default constructor; initializes _img by calling AssemblyInfo.GetImage(AssemblyNames.RealtimeSettings.ToString()).
  • RealtimeSettingsImageAttribute(string s)
    Constructor accepting a string argument (unused); also initializes _img via the same AssemblyInfo.GetImage(...) call.
  • override BitmapImage AssemblyImage
    Gets the assembly image by calling AssemblyInfo.GetImage(AssemblyNames.RealtimeSettings.ToString()). Returns a BitmapImage.
  • override string AssemblyName
    Returns "RealtimeSettings" (via AssemblyNames.RealtimeSettings.ToString()).
  • override string AssemblyGroup
    Returns "Administrative" (via eAssemblyGroups.Administrative.ToString()).
  • override eAssemblyRegion AssemblyRegion
    Throws NotImplementedException.
  • override eAssemblyRegion GetAssemblyRegion()
    Throws NotImplementedException.
  • override Type GetAttributeType()
    Returns typeof(ImageAttribute).
  • override BitmapImage GetAssemblyImage()
    Returns AssemblyImage.
  • override string GetAssemblyName()
    Returns AssemblyName.
  • override string GetAssemblyGroup()
    Returns AssemblyGroup.

3. Invariants

  • RealtimeSettingsModule must be instantiated with a non-null IUnityContainer reference; otherwise, Initialize() will throw a NullReferenceException.
  • Type registration via Initialize() must occur only once per module lifecycle; repeated calls (e.g., due to misordered initialization) may cause duplicate registrations or runtime errors depending on Unitys behavior.
  • AssemblyImage, AssemblyName, and AssemblyGroup are computed at runtime via static calls to AssemblyInfo.GetImage(...) and string conversions of AssemblyNames/eAssemblyGroups. These values are expected to be stable and valid at assembly load time.
  • AssemblyRegion and GetAssemblyRegion() are explicitly unimplemented and will always throw NotImplementedException. Any consumer relying on region metadata will fail at runtime.

4. Dependencies

Dependencies of this module:

  • DTS.Common and DTS.Common.Interface (for AssemblyInfo, AssemblyNames, eAssemblyGroups, ImageAttribute, eAssemblyRegion)
  • Prism.Modularity and Prism.Ioc (for IModule, IContainerRegistry, IContainerProvider)
  • Unity (for IUnityContainer)
  • System.Windows.Media.Imaging (for BitmapImage)
  • System.ComponentModel.Composition (for [Export] and [Module] attributes)

Dependencies on this module:

  • The host application (e.g., shell or main UI) likely consumes RealtimeSettingsImageAttribute via reflection on the assembly to render module metadata (name, group, image) on the main screen.
  • Other modules or services may resolve IRealtimeSettingsView or IRealtimeSettingsViewModel via the Unity container after RealtimeSettingsModule.Initialize() has run.

5. Gotchas

  • RegisterTypes ignores its parameter: Although RegisterTypes receives an IContainerRegistry, it calls Initialize(), which uses the private _unityContainer (IUnityContainer). This violates Prisms intended pattern (where IContainerRegistry should be used for registration) and may cause issues if the module is used in a non-Unity Prism environment or if container resolution is decoupled.
  • Unimplemented region metadata: AssemblyRegion and GetAssemblyRegion() throw NotImplementedException. Any UI or tooling expecting region data will crash.
  • Redundant constructor overloads: The RealtimeSettingsImageAttribute(string s) constructor accepts a parameter that is never used. This may be legacy or placeholder code.
  • No error handling in image loading: If AssemblyInfo.GetImage(...) fails (e.g., missing image resource), the exception propagates during attribute instantiation or property access, potentially causing assembly load failures.
  • Assumes singleton registration: The module registers views/viewmodels as singletons, but no documentation clarifies whether this is intentional (e.g., shared state) or accidental (e.g., should be transient/scoped).