A module is a .NET assembly that has attributes, and contains classes that the CAB can find and use.
Dependency affects the loading sequence.
To create a module
- Create a new class library project or Windows control library project.
- Add a reference to Microsoft.Practices.CompositeUI and Microsoft.Practices.ObjectBuilder
- Add a ModuleAttribute to the project so that other modules can identify your module.
Add the following line to the AssemblyInfo.cs file.
[assembly: Microsoft.Practices.CompositeUI.Module("mainMod")]
To create a module initializer
- Create a new public class in the library project.
- Modify the class to inherit from the Microsoft.Practices.CompositeUI.ModuleInit class.
- If you want to add services programmatically to the module, override the AddServices method of the ModuleInit class.
- If you want to display the user-interface or perform custom logic on startup, override the Load method of the ModuleInit class.
To add dependencies to the module
- Either in the ModuleInit class or in the AssemblyInfo file, add module dependencies as shown in the following code.
[assembly: Microsoft.Practices.CompositeUI.ModuleDependency("TheModuleYouDependOn")]
To load modules when the application starts, you must use a catalog file to list the modules to load. The default name for this file is ProfileCatalog.xml.
To load a module
- Add a new XML file to the main project named ProfileCatalog.xml.
- Edit the contents of ProfileCatalog.xml to list the appropriate modules to load as shown in the following code.
No comments:
Post a Comment