Files
DP44/docs/ai/DataPRO/DataPRO/ModuleCatalog.md

49 lines
3.1 KiB
Markdown
Raw Normal View History

2026-04-17 14:55:32 -04:00
---
source_files:
- DataPRO/DataPRO/ModuleCatalog/AggregateModuleCatalog.cs
generated_at: "2026-04-17T16:14:19.171251+00:00"
model: "zai-org/GLM-5-FP8"
schema_version: 1
sha256: "df0afddd9c0d4a5d"
---
# ModuleCatalog
### Purpose
This module provides an `AggregateModuleCatalog` class that implements the Prism `IModuleCatalog` interface to aggregate multiple module catalogs into a single unified catalog. It enables the application to combine modules from different catalog sources (e.g., configuration-based, directory-based, or dynamically loaded catalogs) while presenting them through a single interface to the Prism modularity system.
### Public Interface
**Class: `AggregateModuleCatalog`** (implements `IModuleCatalog`)
- **`AggregateModuleCatalog()`** - Constructor that initializes the aggregate catalog with a default `Microsoft.Practices.Prism.Modularity.ModuleCatalog` as the first catalog.
- **`void AddCatalog(IModuleCatalog catalog)`** - Adds a module catalog to the aggregate. Throws `ArgumentNullException` if `catalog` is null.
- **`IEnumerable<ModuleInfo> Modules`** (property) - Returns all `ModuleInfo` instances across all aggregated catalogs via `SelectMany`.
- **`IEnumerable<ModuleInfo> GetDependentModules(ModuleInfo moduleInfo)`** - Returns dependent modules for the given `moduleInfo` by locating the owning catalog and delegating the call. Uses `Single()` to find the catalog containing the module.
- **`IEnumerable<ModuleInfo> CompleteListWithDependencies(IEnumerable<ModuleInfo> modules)`** - Returns a complete list of modules including all dependencies. Groups modules by their owning catalog and delegates to each catalog's `CompleteListWithDependencies`.
- **`void Initialize()`** - Initializes all aggregated catalogs by calling `Initialize()` on each.
- **`void AddModule(ModuleInfo moduleInfo)`** - Adds a `ModuleInfo` to the first catalog in the list (`_catalogs[0]`).
### Invariants
- The `_catalogs` list is never null; it is initialized in the constructor and always contains at least one catalog (the default `ModuleCatalog`).
- The first catalog (`_catalogs[0]`) is always an instance of `Microsoft.Practices.Prism.Modularity.ModuleCatalog`.
- `AddCatalog` will throw `ArgumentNullException` if passed a null catalog.
- `GetDependentModules` assumes each `ModuleInfo` exists in exactly one catalog; behavior is undefined if a module appears in multiple catalogs.
### Dependencies
**Depends on:**
- `Microsoft.Practices.Prism.Modularity` - `IModuleCatalog`, `ModuleCatalog`, `ModuleInfo`
**Depended on by:**
- Not determinable from source alone; likely consumed by application bootstrapping/initialization code.
### Gotchas
- **`AddModule` always adds to the first catalog only** (`_catalogs[0]`), not to all catalogs or a user-specified catalog. This may cause confusion if developers expect modules to be distributed across catalogs.
- **`GetDependentModules` uses `Single()`** which will throw `InvalidOperationException` if the module is not found in any catalog or exists in multiple catalogs.
- The XML documentation comments reference `DataPro.Main.ModuleCatalog` which appears to be a stale/incorrect reference; the actual class is