Class ModuleCatalog
The ModuleCatalog holds information about the modules that can be used by the application. Each module is described in a ModuleInfo class, that records the name, type and location of the module. It also verifies that the ModuleCatalog is internally valid. That means that it does not have:
The ModuleCatalog also serves as a baseclass for more specialized Catalogs .
Implements
Namespace: Sartorius.SAF.Presentation.Modularity
Assembly: Sartorius.SAF.Presentation.dll
Syntax
public class ModuleCatalog : IModuleCatalogConstructors
View SourceModuleCatalog()
Initializes a new instance of the ModuleCatalog class.
Declaration
public ModuleCatalog()ModuleCatalog(IEnumerable<ModuleInfo>)
Initializes a new instance of the ModuleCatalog class while providing an initial list of ModuleInfos.
Declaration
public ModuleCatalog(IEnumerable<ModuleInfo> modules)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Collections.Generic.IEnumerable<ModuleInfo> | modules | The initial list of modules. | 
Properties
View SourceGrouplessModules
Returns the list of ModuleInfos that are not contained within any ModuleInfoGroup.
Declaration
protected IEnumerable<ModuleInfo> GrouplessModules { get; }Property Value
| Type | Description | 
|---|---|
| System.Collections.Generic.IEnumerable<ModuleInfo> | The groupless modules. | 
Groups
Gets the ModuleInfoGroups that have been added to the ModuleCatalog.
Declaration
public IEnumerable<ModuleInfoGroup> Groups { get; }Property Value
| Type | Description | 
|---|---|
| System.Collections.Generic.IEnumerable<ModuleInfoGroup> | The groups. | 
Items
Gets the items in the ModuleCatalog. This property is mainly used to add ModuleInfoGroups or ModuleInfos through XAML.
Declaration
public Collection<IModuleCatalogItem> Items { get; }Property Value
| Type | Description | 
|---|---|
| System.Collections.ObjectModel.Collection<IModuleCatalogItem> | The items in the catalog. | 
Modules
Gets all the ModuleInfo classes that are in the ModuleCatalog, regardless if they are within a ModuleInfoGroup or not.
Declaration
public virtual IEnumerable<ModuleInfo> Modules { get; }Property Value
| Type | Description | 
|---|---|
| System.Collections.Generic.IEnumerable<ModuleInfo> | The modules. | 
Validated
Gets or sets a value that remembers whether the ModuleCatalog has been validated already.
Declaration
protected bool Validated { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
Methods
View SourceAddGroup(InitializationMode, String, ModuleInfo[])
Creates and adds a ModuleInfoGroup to the catalog.
Declaration
public virtual ModuleCatalog AddGroup(InitializationMode initializationMode, string refValue, params ModuleInfo[] moduleInfos)Parameters
| Type | Name | Description | 
|---|---|---|
| InitializationMode | initializationMode | Stage on which the module group to be added will be initialized. | 
| System.String | refValue | Reference to the location of the module group to be added. | 
| ModuleInfo[] | moduleInfos | Collection of ModuleInfo included in the group. | 
Returns
| Type | Description | 
|---|---|
| ModuleCatalog | ModuleCatalog with the added module group. | 
AddModule(ModuleInfo)
Adds a ModuleInfo to the ModuleCatalog.
Declaration
public virtual void AddModule(ModuleInfo moduleInfo)Parameters
| Type | Name | Description | 
|---|---|---|
| ModuleInfo | moduleInfo | The ModuleInfo to add. | 
AddModule(String, String, InitializationMode, String[])
Adds a groupless ModuleInfo to the catalog.
Declaration
public ModuleCatalog AddModule(string moduleName, string moduleType, InitializationMode initializationMode, params string[] dependsOn)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | moduleName | Name of the module to be added. | 
| System.String | moduleType | System.Type of the module to be added. | 
| InitializationMode | initializationMode | Stage on which the module to be added will be initialized. | 
| System.String[] | dependsOn | Collection of module names (ModuleName) of the modules on which the module to be added logically depends on. | 
Returns
| Type | Description | 
|---|---|
| ModuleCatalog | The same ModuleCatalog instance with the added module. | 
AddModule(String, String, String, InitializationMode, String[])
Adds a groupless ModuleInfo to the catalog.
Declaration
public ModuleCatalog AddModule(string moduleName, string moduleType, string refValue, InitializationMode initializationMode, params string[] dependsOn)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | moduleName | Name of the module to be added. | 
| System.String | moduleType | System.Type of the module to be added. | 
| System.String | refValue | Reference to the location of the module to be added assembly. | 
| InitializationMode | initializationMode | Stage on which the module to be added will be initialized. | 
| System.String[] | dependsOn | Collection of module names (ModuleName) of the modules on which the module to be added logically depends on. | 
Returns
| Type | Description | 
|---|---|
| ModuleCatalog | The same ModuleCatalog instance with the added module. | 
AddModule(String, String, String[])
Adds a groupless ModuleInfo to the catalog.
Declaration
public ModuleCatalog AddModule(string moduleName, string moduleType, params string[] dependsOn)Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | moduleName | Name of the module to be added. | 
| System.String | moduleType | System.Type of the module to be added. | 
| System.String[] | dependsOn | Collection of module names (ModuleName) of the modules on which the module to be added logically depends on. | 
Returns
| Type | Description | 
|---|---|
| ModuleCatalog | The same ModuleCatalog instance with the added module. | 
AddModule(Type, InitializationMode, String[])
Adds a groupless ModuleInfo to the catalog.
Declaration
public ModuleCatalog AddModule(Type moduleType, InitializationMode initializationMode, params string[] dependsOn)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Type | moduleType | System.Type of the module to be added. | 
| InitializationMode | initializationMode | Stage on which the module to be added will be initialized. | 
| System.String[] | dependsOn | Collection of module names (ModuleName) of the modules on which the module to be added logically depends on. | 
Returns
| Type | Description | 
|---|---|
| ModuleCatalog | The same ModuleCatalog instance with the added module. | 
AddModule(Type, String[])
Adds a groupless ModuleInfo to the catalog.
Declaration
public ModuleCatalog AddModule(Type moduleType, params string[] dependsOn)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Type | moduleType | System.Type of the module to be added. | 
| System.String[] | dependsOn | Collection of module names (ModuleName) of the modules on which the module to be added logically depends on. | 
Returns
| Type | Description | 
|---|---|
| ModuleCatalog | The same ModuleCatalog instance with the added module. | 
CompleteListWithDependencies(IEnumerable<ModuleInfo>)
Returns a list of ModuleInfos that contain both the ModuleInfos in
modules, but also all the modules they depend on.
Declaration
public virtual IEnumerable<ModuleInfo> CompleteListWithDependencies(IEnumerable<ModuleInfo> modules)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Collections.Generic.IEnumerable<ModuleInfo> | modules | The modules to get the dependencies for. | 
Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IEnumerable<ModuleInfo> | A list of ModuleInfo that contains both all ModuleInfos in  | 
CreateFromXaml(Stream)
Creates a ModuleCatalog from XAML.
Declaration
public static ModuleCatalog CreateFromXaml(Stream xamlStream)Parameters
| Type | Name | Description | 
|---|---|---|
| System.IO.Stream | xamlStream | System.IO.Stream that contains the XAML declaration of the catalog. | 
Returns
| Type | Description | 
|---|---|
| ModuleCatalog | An instance of ModuleCatalog built from the XAML. | 
CreateFromXaml(Uri)
Creates a ModuleCatalog from a XAML included as an Application Resource.
Declaration
public static ModuleCatalog CreateFromXaml(Uri builderResourceUri)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Uri | builderResourceUri | Relative System.Uri that identifies the XAML included as an Application Resource. | 
Returns
| Type | Description | 
|---|---|
| ModuleCatalog | An instance of ModuleCatalog build from the XAML. | 
EnsureCatalogValidated()
Ensures that the catalog is validated.
Declaration
protected virtual void EnsureCatalogValidated()GetDependentModules(ModuleInfo)
Return the list of ModuleInfos that moduleInfo depends on.
Declaration
public virtual IEnumerable<ModuleInfo> GetDependentModules(ModuleInfo moduleInfo)Parameters
| Type | Name | Description | 
|---|---|---|
| ModuleInfo | moduleInfo | The ModuleInfo to get the | 
Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IEnumerable<ModuleInfo> | An enumeration of ModuleInfo that  | 
Remarks
If the ModuleCatalog was not yet validated, this method will call Validate().
GetDependentModulesInner(ModuleInfo)
Returns the ModuleInfo on which the received module dependens on.
Declaration
protected virtual IEnumerable<ModuleInfo> GetDependentModulesInner(ModuleInfo moduleInfo)Parameters
| Type | Name | Description | 
|---|---|---|
| ModuleInfo | moduleInfo | Module whose dependant modules are requested. | 
Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IEnumerable<ModuleInfo> | Collection of ModuleInfo dependants of  | 
Initialize()
Initializes the catalog, which may load and validate the modules.
Declaration
public virtual void Initialize()Exceptions
| Type | Condition | 
|---|---|
| ModularityException | When validation of the ModuleCatalog fails, because this method calls Validate(). | 
InnerLoad()
Does the actual work of loading the catalog. The base implementation does nothing.
Declaration
protected virtual void InnerLoad()Load()
Loads the catalog if necessary.
Declaration
public void Load()SolveDependencies(IEnumerable<ModuleInfo>)
Checks for cyclic dependencies, by calling the dependency solver.
Declaration
protected static string[] SolveDependencies(IEnumerable<ModuleInfo> modules)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Collections.Generic.IEnumerable<ModuleInfo> | modules | A list of ModuleInfo. | 
Returns
| Type | Description | 
|---|---|
| System.String[] | 
Sort(IEnumerable<ModuleInfo>)
Sorts a list of ModuleInfos. This method is called by CompleteListWithDependencies(IEnumerable<ModuleInfo>) to return a sorted list.
Declaration
protected virtual IEnumerable<ModuleInfo> Sort(IEnumerable<ModuleInfo> modules)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Collections.Generic.IEnumerable<ModuleInfo> | modules | The ModuleInfos to sort. | 
Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.IEnumerable<ModuleInfo> | Sorted list of ModuleInfos | 
Validate()
Validates the ModuleCatalog.
Declaration
public virtual void Validate()Exceptions
| Type | Condition | 
|---|---|
| ModularityException | When validation of the ModuleCatalog fails. | 
ValidateCrossGroupDependencies()
Ensures that there are no dependencies between modules on different groups.
Declaration
protected virtual void ValidateCrossGroupDependencies()Remarks
A group-less module can only depend on other group-less modules. A module within a group can depend on other modules within the same group and/or on group-less modules.
ValidateDependencies(IEnumerable<ModuleInfo>)
Ensures that all the dependencies within modules refer to ModuleInfos
within that list.
Declaration
protected static void ValidateDependencies(IEnumerable<ModuleInfo> modules)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Collections.Generic.IEnumerable<ModuleInfo> | modules | The modules to validate modules for. | 
Exceptions
| Type | Condition | 
|---|---|
| ModularityException | Throws if a ModuleInfo in  | 
| System.ArgumentNullException | Throws if  | 
ValidateDependenciesInitializationMode()
Ensures that there are no modules marked to be loaded WhenAvailable depending on modules loaded OnDemand
Declaration
protected virtual void ValidateDependenciesInitializationMode()ValidateDependencyGraph()
Ensures that there are no cyclic dependencies.
Declaration
protected virtual void ValidateDependencyGraph()ValidateUniqueModules()
Makes sure all modules have an Unique name.
Declaration
protected virtual void ValidateUniqueModules()Exceptions
| Type | Condition | 
|---|---|
| DuplicateModuleException | Thrown if the names of one or more modules are not unique. |