6.1 KiB
6.1 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
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 module’s 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:IRealtimeSettingsView→RealtimeSettingsViewIRealtimeSettingsViewModel→RealtimeSettingsViewModel
This method is called byRegisterTypes, 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 toInitialize(), performing the same type registrations. Note: Although the parameter is of typeIContainerRegistry, the method internally uses the stored_unityContainer(of typeIUnityContainer) rather thancontainerRegistry. This suggests potential inconsistency with Prism’s expected pattern.
RealtimeSettingsImageAttribute
RealtimeSettingsImageAttribute()
Default constructor; initializes_imgby callingAssemblyInfo.GetImage(AssemblyNames.RealtimeSettings.ToString()).RealtimeSettingsImageAttribute(string s)
Constructor accepting a string argument (unused); also initializes_imgvia the sameAssemblyInfo.GetImage(...)call.override BitmapImage AssemblyImage
Gets the assembly image by callingAssemblyInfo.GetImage(AssemblyNames.RealtimeSettings.ToString()). Returns aBitmapImage.override string AssemblyName
Returns"RealtimeSettings"(viaAssemblyNames.RealtimeSettings.ToString()).override string AssemblyGroup
Returns"Administrative"(viaeAssemblyGroups.Administrative.ToString()).override eAssemblyRegion AssemblyRegion
ThrowsNotImplementedException.override eAssemblyRegion GetAssemblyRegion()
ThrowsNotImplementedException.override Type GetAttributeType()
Returnstypeof(ImageAttribute).override BitmapImage GetAssemblyImage()
ReturnsAssemblyImage.override string GetAssemblyName()
ReturnsAssemblyName.override string GetAssemblyGroup()
ReturnsAssemblyGroup.
3. Invariants
RealtimeSettingsModulemust be instantiated with a non-nullIUnityContainerreference; otherwise,Initialize()will throw aNullReferenceException.- 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 Unity’s behavior. AssemblyImage,AssemblyName, andAssemblyGroupare computed at runtime via static calls toAssemblyInfo.GetImage(...)and string conversions ofAssemblyNames/eAssemblyGroups. These values are expected to be stable and valid at assembly load time.AssemblyRegionandGetAssemblyRegion()are explicitly unimplemented and will always throwNotImplementedException. Any consumer relying on region metadata will fail at runtime.
4. Dependencies
Dependencies of this module:
DTS.CommonandDTS.Common.Interface(forAssemblyInfo,AssemblyNames,eAssemblyGroups,ImageAttribute,eAssemblyRegion)Prism.ModularityandPrism.Ioc(forIModule,IContainerRegistry,IContainerProvider)Unity(forIUnityContainer)System.Windows.Media.Imaging(forBitmapImage)System.ComponentModel.Composition(for[Export]and[Module]attributes)
Dependencies on this module:
- The host application (e.g., shell or main UI) likely consumes
RealtimeSettingsImageAttributevia reflection on the assembly to render module metadata (name, group, image) on the main screen. - Other modules or services may resolve
IRealtimeSettingsVieworIRealtimeSettingsViewModelvia the Unity container afterRealtimeSettingsModule.Initialize()has run.
5. Gotchas
RegisterTypesignores its parameter: AlthoughRegisterTypesreceives anIContainerRegistry, it callsInitialize(), which uses the private_unityContainer(IUnityContainer). This violates Prism’s intended pattern (whereIContainerRegistryshould 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:
AssemblyRegionandGetAssemblyRegion()throwNotImplementedException. 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).