Monday, May 21, 2007

Stage 2: Creating and Loading the Module

  1. Add a Class Library project named MyModule in the solution ShellApplication.sln
  2. Project's outputpath should be \ShellApplication\bin\Debug\
  3. In Add Reference Select these three DLLs:
    Microsoft.Practices.CompositeUI.dll
    Microsoft.Practices.CompositeUI.WinForms.dll
    Microsoft.Practices.ObjectBuilder.dll
  4. Add a new class named MyWorkItem.cs
    using Microsoft.Practices.CompositeUI;
    inherits from WorkItem as below
    public class MyWorkItem : WorkItem
    {}
  5. Add a class named MymoduleInit.cs
    using Microsoft.Practices.CompositeUI;
    using Microsoft.Practices.CompositeUI.Services;
    using System.Windows.Forms;
    • inherit from ModuleInit as shown here
      public class MyModuleInit : ModuleInit
    • Add the following variable to reference the WorkItemTypeCatalogService
      private IWorkItemTypeCatalogService myCatalogService;
    • Add the following public property to the class that sets the value of the myCatalogService variable.
      [ServiceDependency]
      public IWorkItemTypeCatalogService myWorkItemCatalog
      {
      set { myCatalogService = value; }
      }
    • Override the Load method of the ModuleInit class
      public override void Load()
      {
      base.Load();
      myCatalogService.RegisterWorkItem <MyWorkItem>();
      }
  6. instruct the CAB to load the new module
    In the ShellApplication project, open the NewItem dialog box and select XML File. Name it ProfileCatalog.xml.
    < ?xml version="1.0" encoding="utf-8" ? &gt
    < SolutionProfile xmlns="http://schemas.microsoft.com/pag/cab-profile" %gt
    &lt Modules >
    &lt ModuleInfo AssemblyFile="MyModule.dll" />
    &lt/Modules>
    &lt/SolutionProfile>
  7. Save and Run the application

No comments: