4.7 KiB
4.7 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-16T12:02:00.610314+00:00 | zai-org/GLM-5-FP8 | 1 | 6c5b3cbd6c5102fe |
Documentation: AggregateModuleCatalog
1. Purpose
The AggregateModuleCatalog class provides a composite implementation of the Prism IModuleCatalog interface. It allows the application to combine multiple distinct module catalogs (e.g., a DirectoryModuleCatalog, a ModuleCatalog, etc.) into a single logical unit. This enables modules to be discovered and loaded from heterogeneous sources simultaneously while presenting a unified interface to the module management system.
2. Public Interface
-
AggregateModuleCatalog()- Signature:
public AggregateModuleCatalog() - Behavior: Initializes a new instance of the class. It pre-populates the internal list of catalogs with a default instance of
ModuleCatalog(located at index 0).
- Signature:
-
AddCatalog(IModuleCatalog catalog)- Signature:
public void AddCatalog(IModuleCatalog catalog) - Behavior: Adds a specific
IModuleCataloginstance to the aggregate collection. - Validation: Throws
ArgumentNullExceptionif the providedcatalogis null.
- Signature:
-
Modules- Signature:
public IEnumerable<ModuleInfo> Modules { get; } - Behavior: Aggregates and returns the
ModuleInfoobjects from all catalogs currently held in the collection.
- Signature:
-
GetDependentModules(ModuleInfo moduleInfo)- Signature:
public IEnumerable<ModuleInfo> GetDependentModules(ModuleInfo moduleInfo) - Behavior: Locates the specific catalog that contains the provided
moduleInfoand delegates the call to that catalog'sGetDependentModulesmethod.
- Signature:
-
CompleteListWithDependencies(IEnumerable<ModuleInfo> modules)- Signature:
public IEnumerable<ModuleInfo> CompleteListWithDependencies(IEnumerable<ModuleInfo> modules) - Behavior: Groups the provided modules by their owning catalog and calls
CompleteListWithDependencieson each respective catalog, returning the combined result.
- Signature:
-
Initialize()- Signature:
public void Initialize() - Behavior: Iterates through all catalogs in the collection and calls their
Initialize()method.
- Signature:
-
AddModule(ModuleInfo moduleInfo)- Signature:
public void AddModule(ModuleInfo moduleInfo) - Behavior: Adds the provided
moduleInfospecifically to the first catalog in the internal list (_catalogs[0]), which is the defaultModuleCatalogcreated in the constructor.
- Signature:
3. Invariants
- Non-Empty Catalog List: The internal
_catalogslist is never empty. It is initialized with a defaultModuleCatalogin the constructor. - Module Ownership: A
ModuleInfoinstance must exist in exactly one of the aggregated catalogs for dependency resolution to succeed. The methodsGetDependentModulesandCompleteListWithDependenciesrely on_catalogs.Single(...)logic to find the owner; if a module appears in multiple catalogs or no catalogs, theSingleoperation will throw anInvalidOperationException. - AddModule Target: The
AddModulemethod always targets the first catalog in the collection (index 0).
4. Dependencies
- External Dependencies:
Microsoft.Practices.Prism.Modularity: The class implementsIModuleCatalogand utilizes typesModuleInfoandModuleCatalog.
- Standard Libraries:
SystemSystem.Collections.GenericSystem.Linq
5. Gotchas
- Hardcoded AddModule Behavior: Calling
AddModuledoes not add the module to the "aggregate" generally; it specifically adds it to the defaultModuleCatalogstored at_catalogs[0]. If a developer adds a new catalog viaAddCatalogand expectsAddModuleto interact with that new catalog, they will be mistaken. - Strict Uniqueness Constraint: The dependency resolution methods use
System.Linq.Singleto locate the catalog owning a specific module. If the sameModuleInfoinstance (or equivalent identity) is added to multiple sub-catalogs, the application will crash during dependency resolution becauseSingleexpects exactly one match. - Commented-Out Validation Logic: The
AddCatalogmethod contains a large block of commented-out code attempting to validateDirectoryModuleCatalogpaths. This suggests unfinished validation logic or technical debt regarding duplicate directory paths that was abandoned. - Exception Message Typo: In
AddCatalog, theArgumentNullExceptionis instantiated with a string literal$"catalog"using string interpolation unnecessarily. While functional, it deviates from standard practices (usuallynameof(catalog)).