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

6.1 KiB
Raw Permalink Blame History

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DataPRO/Modules/SystemSettings/UISettings/UISettingsModule.cs
2026-04-16T04:39:31.289860+00:00 Qwen/Qwen3-Coder-Next-FP8 1 b65049df89cf8545

UISettings

Documentation: UISettingsModule (DataPRO/Modules/SystemSettings/UISettings/UISettingsModule.cs)


1. Purpose

This module registers the UI settings view and view model as singleton services within the Unity dependency injection container for use in the applications system settings UI. It serves as the Prism module entry point for the UISettings feature, enabling modular loading and dependency resolution of the UI settings component. It also provides assembly-level metadata (image and group) via the UISettingsImageAttribute, allowing the main screen to display the module as part of the Administrative group.


2. Public Interface

Class: UISettingsModule

  • public UISettingsModule(IUnityContainer unityContainer)
    Constructor. Accepts a Unity container via dependency injection and stores it for later use in type registration.

  • public void Initialize()
    Registers the IUISettingsView interface to UISettingsView, and IUISettingsViewModel to UISettingsViewModel, both as singleton registrations in the Unity container.

  • public void OnInitialized(IContainerProvider containerProvider)
    Currently empty; no logic implemented.

  • public void RegisterTypes(IContainerRegistry containerRegistry)
    Delegates to Initialize(), performing the same type registrations. (Note: IContainerRegistry is a Prism abstraction, but Initialize() uses IUnityContainer directly — see Gotchas.)

Attribute: UISettingsImageAttribute

  • public UISettingsImageAttribute()
    Default constructor; delegates to the overloaded constructor with null.

  • public UISettingsImageAttribute(string s)
    Constructor accepting a string parameter (unused); initializes _img by calling AssemblyInfo.GetImage(AssemblyNames.UISettings.ToString()).

  • public override BitmapImage AssemblyImage { get; }
    Returns the assembly image for UISettings, retrieved via AssemblyInfo.GetImage(...). Uses lazy initialization (caches in _img).

  • public override Type GetAttributeType()
    Returns typeof(ImageAttribute).

  • public override BitmapImage GetAssemblyImage()
    Returns the value of AssemblyImage.

  • public override string AssemblyName { get; }
    Returns "UISettings" (from AssemblyNames.UISettings.ToString()), cached in _name.

  • public override string GetAssemblyName()
    Returns the value of AssemblyName.

  • public override string AssemblyGroup { get; }
    Returns "Administrative" (from eAssemblyGroups.Administrative.ToString()), cached in _group.

  • public override string GetAssemblyGroup()
    Returns the value of AssemblyGroup.

  • public override eAssemblyRegion AssemblyRegion { get; }
    Throws NotImplementedException — not implemented.

  • public override eAssemblyRegion GetAssemblyRegion()
    Throws NotImplementedException — not implemented.


3. Invariants

  • UISettingsModule must be loaded as a Prism module (via [Export(typeof(IModule))] and [Module(ModuleName = "UISettings")]).
  • IUISettingsView and IUISettingsViewModel are registered as singleton instances in the Unity container during module initialization.
  • AssemblyImage, AssemblyName, and AssemblyGroup are statically derived from AssemblyNames.UISettings and eAssemblyGroups.Administrative, and are expected to be consistent across builds.
  • AssemblyRegion and GetAssemblyRegion() are not implemented — callers must avoid invoking them.

4. Dependencies

Imports (from source):

  • System, System.ComponentModel.Composition, System.Windows.Media.Imaging — WPF imaging and MEF support.
  • DTS.Common and DTS.Common.Interface — internal common library (contains AssemblyInfo, AssemblyNames, eAssemblyGroups, ImageAttribute, eAssemblyRegion).
  • Prism.Ioc, Prism.Modularity — Prism framework for DI and module loading.
  • Unity — Unity container API (IUnityContainer, IContainerRegistry).

Consumers (inferred):

  • The Prism bootstrapper/module catalog — loads UISettingsModule at runtime.
  • The main UI shell — consumes UISettingsImageAttribute (via assembly-level attribute reflection) to render module metadata (image, name, group).
  • Any code resolving IUISettingsView or IUISettingsViewModel via Unity — e.g., views, view models, or services needing to display or interact with the UI settings UI.

5. Gotchas

  • RegisterTypes uses Prisms IContainerRegistry, but internally calls Initialize() which uses Unitys IUnityContainer.
    This implies tight coupling to Unity and may break if the container abstraction changes or if the module is used in a non-Unity Prism setup. The containerRegistry parameter is unused.

  • AssemblyRegion and GetAssemblyRegion() throw NotImplementedException.
    Any code expecting region metadata (e.g., for UI grouping or filtering) will crash if this attribute is used in that context.

  • _img, _name, and _group are lazily initialized and cached in private fields, but not thread-safely.
    While unlikely to cause issues (assembly metadata is typically read once at startup), concurrent access during initialization could lead to race conditions.

  • The string s parameter in UISettingsImageAttribute(string s) is unused.
    Likely legacy or placeholder; may mislead developers into thinking it configures something.

  • No validation is performed on AssemblyInfo.GetImage(...).
    If the image resource is missing or malformed, the exception occurs at runtime (e.g., NullReferenceException or WPF imaging error), not at registration time.

  • OnInitialized is empty — no post-initialization logic is defined.
    If future logic is added here, it must be compatible with the current singleton registration model.


Documentation generated from DataPRO/Modules/SystemSettings/UISettings/UISettingsModule.cs.