6.5 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-16T04:34:59.163908+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 674f1fac51c6e6cb |
DatabaseServices
Documentation: DatabaseServicesModule
1. Purpose
The DatabaseServicesModule is a Prism module responsible for registering core database-related UI components (views and view models) into the Unity dependency injection container during application startup. It enables modular composition of the database services feature set within the larger application architecture, specifically integrating with Prism’s module loading mechanism and Unity for dependency resolution. It also contributes metadata (name, image, group, region) to the main UI for discoverability and placement of database-related components.
2. Public Interface
DatabaseServicesModule class
-
public DatabaseServicesModule(IUnityContainer unityContainer)
Constructor. Accepts a Unity container via dependency injection and stores it for later use in type registration. -
public void Initialize()
Registers the following view/view-model pairs as singleton mappings in the Unity container:IDatabaseCopyView→DatabaseCopyViewIDatabaseCopyViewModel→DatabaseCopyViewModelIDatabaseStatusBarView→DatabaseStatusBarViewIDatabaseStatusBarViewModel→DatabaseStatusBarViewModelIDatabaseSwitchView→DatabaseSwitchViewIDatabaseSwitchViewModel→DatabaseSwitchViewModel
Note: This method is called both directly by Prism’sIModule.Initialize()and indirectly viaRegisterTypes().
-
public void OnInitialized(IContainerProvider containerProvider)
Currently empty; no logic implemented. -
public void RegisterTypes(IContainerRegistry containerRegistry)
Delegates toInitialize(). This is required by Prism’sIModuleinterface (viaIContainerRegistry), but the implementation ignorescontainerRegistryand uses the injected_unityContainerinstead.
DatabaseServicesModuleNameAttribute class
-
public override string AssemblyName { get; }
Returns"DatabaseServices"(value ofAssemblyNames.DatabaseServices.ToString()). -
public override string GetAssemblyName()
Returns the same value asAssemblyName. -
public override Type GetAttributeType()
Returnstypeof(TextAttribute).
DatabaseServicesModuleImageAttribute class
-
public override BitmapImage AssemblyImage { get; }
Loads and returns aBitmapImageby callingAssemblyInfo.GetImage("DatabaseServices"). -
public override string AssemblyName { get; }
Returns"DatabaseServices". -
public override string AssemblyGroup { get; }
Returns"Prepare"(value ofeAssemblyGroups.Prepare.ToString()). -
public override eAssemblyRegion AssemblyRegion { get; }
ReturnseAssemblyRegion.DatabaseServicesRegion. -
public override string GetAssemblyName()
Returns"DatabaseServices". -
public override string GetAssemblyGroup()
Returns"Prepare". -
public override eAssemblyRegion GetAssemblyRegion()
ReturnseAssemblyRegion.DatabaseServicesRegion. -
public override BitmapImage GetAssemblyImage()
Returns the value ofAssemblyImage. -
public override Type GetAttributeType()
Returnstypeof(ImageAttribute).
3. Invariants
- Singleton Registration: All view/view-model pairs registered in
Initialize()are registered as singletons (default Unity behavior forRegisterType<T, TImpl>()without specifyingLifetimeManager). - Assembly Name Consistency: Both attributes (
DatabaseServicesModuleNameAttribute,DatabaseServicesModuleImageAttribute) consistently use"DatabaseServices"as the assembly name (viaAssemblyNames.DatabaseServices). - Group & Region Constraints:
AssemblyGroupis always"Prepare"(fromeAssemblyGroups.Prepare).AssemblyRegionis alwayseAssemblyRegion.DatabaseServicesRegion.
- Image Loading:
AssemblyImageis loaded exactly once per instance (cached in_img), usingAssemblyInfo.GetImage("DatabaseServices"). No fallback or error handling is visible in the source.
4. Dependencies
Dependencies of this module:
- Prism.Modularity (
IModule): Required for module discovery and initialization. - Unity (
IUnityContainer,IContainerProvider,IContainerRegistry): Used for DI container registration. - DTS.Common (
AssemblyNames,eAssemblyGroups,eAssemblyRegion,AssemblyInfo): Provides metadata constants and image-loading utilities. - System.ComponentModel.Composition (
Export): Enables Prism to discover this module via MEF. - System.Windows.Media.Imaging (
BitmapImage): Required for the image attribute.
Dependencies on this module:
- Prism-based shell/application: The main application must load this module (via Prism module catalog) to register the database services views/view-models.
- UI regions: The
DatabaseServicesRegion(referenced inAssemblyRegion) must be defined elsewhere (e.g., in XAML or shell layout) for views to be injected into.
5. Gotchas
- Redundant
Initialize()call:RegisterTypes()callsInitialize(), butInitialize()is also called directly by Prism. This is safe (idempotent for registration), but indicates potential design redundancy or legacy code. - Ignored
containerRegistry:RegisterTypes()receivesIContainerRegistry containerRegistrybut ignores it in favor of the injected_unityContainer. This couples the module to Unity and may break if another DI container is used. - No error handling for image loading: If
AssemblyInfo.GetImage("DatabaseServices")fails (e.g., missing image resource),_imgmay benullwith no visible fallback or logging. - Hardcoded string
"DatabaseServices": Used in both attributes andAssemblyInfo.GetImage(). A typo or rename inAssemblyNames.DatabaseServiceswould cause runtime issues. - No
OnInitialized()logic: TheOnInitialized()method is empty. If initialization order or cross-module coordination is needed, this is currently unsupported. - Attribute usage: Both attributes are applied at the assembly level (via
[assembly: ...]), meaning they are not tied to theDatabaseServicesModuleclass itself but to the entire assembly. This may cause confusion if multiple modules exist in the same assembly.
None identified beyond the above.