Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

How to: Create a Business Module

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies.
This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Business modules are distinct deployment units of a Composite UI Application Block application that contain business logic elements.

The Smart Client Development Package includes the Visual Studio template named Add Business Module. This template unfolds a new class library project for the module implementation and, optionally, a module interface project. The implementation class library project contains two classes, Module and ModuleConroller. The Module class derives from the Composite UI Application Block class ModuleInit. The Composite UI Application Block calls the Load method of this class on startup. The ModuleController class contains empty methods that you can modify to customize the behavior of the module on startup. For example, you can add services or display user interface items. The interface class library contains constants definitions and empty folders you can use to store interface elements of the module. For example, you can add service interfaces or constants definitions.

Ff647622.note(en-us,PandP.10).gifNote:
This template targets the .NET Framework 3.5 and ignores the target framework version selected in the New Project dialog. This means that you cannot create business modules targeting older .NET Framework versions with this release of the Smart Client Software Factory.

The Business Module template unfolds a class library project. It requires that you have an existing smart client solution open in Visual Studio.

You unfold the Business Module template to create a new business module, which is a Composite UI Application Block module.

To create a business module with the Business Module template

  1. Using Visual Studio, open an existing smart client solution.
  2. In Solution Explorer, right-click either the solution node or a solution folder, point to Smart Client Factory, and then click AddBusiness Module, as shown in Figure 1.

    Ff647622.03-SCSF-HowToAddBM(en-us,PandP.10).png

    Figure 1
    The Add Business Module recipe menu

  3. The Add New Project dialog box appears. If you want, you can change the Name and Location fields for the project. Figure 2 illustrates this dialog box.

    Ff647622.03-SCSF-HowToAddBM2(en-us,PandP.10).png

    Figure 2
    The software factory module project templates

  4. Click OK. The recipe starts the Add Business Module Wizard. Figure 3 illustrates the first page of the wizard.

    Ff647622.03-SCSF-HowToAddBM3(en-us,PandP.10).png

    Figure 3
    The Add Business Module Wizard

  5. (Optional) If you want to create a separate project that contains the public interface for the module, select the Create an interface library for this module check box. (For more information, see Module Interface Separation.)
  6. (Optional) If you want a test project for the module to be created with test classes for your module components, select the Create a unit test project for this module check box.
  7. (Optional) If you want to see a summary of the recipe actions and suggested next steps after the recipe completes, select the Show documentation after recipe completes check box.

You will have the following elements in your solution:

  • A class library project. This is the module class library. It contains a module initialization class and the module WorkItemController.
  • (Optional) A class library project that contains the public interface. This is a project that you can use to define the public interface (for example, constants and services) that you want to share with other modules.
  • (Optional) A test project for the module. This is an empty project that you can use to create your unit tests.
  • An updated profile catalog. The module definition will be added to the <modules> section of the ProfileCatalog.xml file of the Shell project. The Composite Web Application Block uses this information to load the module when the application starts.

Figure 4 illustrates a smart client solution with a business module named BusinessModule1.

Ff647622.03-SCSF-HowToAddBM4(en-us,PandP.10).png

Figure 4
Smart client solution with business module BusinessModule1

Implementation Notes

If you created the business module with a separate interface assembly, the CreateBusinessModule recipe will create constants classes in the implementation assembly that inherit constants classes of the interface assembly. But if you do not create a separate interface project, the CreateBusinessModule recipe will create constants classes that inherit constants classes of Infrastructure.Interface project.

The following are typical tasks that you perform after you create a business module:

  • Implement and register global services in the module controller. To do this, follow these steps:
    1. Add a new class to your project, and then implement it. This will be the service implementation.
    2. In the ModuleController class, implement the AddServices method. Call the WorkItem.Services.Add method or WorkItem.Services.AddNew method to register your service as a module service, or call the WorkItem.RootWorkItem.Services.Add method or WorkItem.RootWorkItem.Services.AddNew method to register your service as a global service.
    3. Optionally, you can use the [Service] attribute to register your service as a global service instead of registering it in the AddServices method of your ModuleController class.

      For more information about registering services, see Adding Services.

        Add menu items in the module controller. To do this, implement the ExtendMenu method in the ModuleController class. You can obtain a reference to the Shell's main menu using the following code.
      WorkItem.UIExtensionSites[UIExtensionSiteNames.MainMenu]
      
      

      For more information, see Showing UIElements.

        Add new items to the tool strip in the shell in the module controller. To do this, implement the ExtendToolStrip method in the ModuleController class. You can obtain a reference to the Shell's main toolbar using the following code.
      WorkItem.UIExtensionSites[UIExtensionSiteNames.MainToolbar]
      
      
        Add views with presenters. You can add views using the Add View (with Presenter) recipe. For information about how to run the recipe, see How to: Add a View with a Presenter.

      For information about how to create a disconnected service agent, see How to: Create a Disconnected Service Agent.

  • Add menu items in the module controller. To do this, implement the ExtendMenu method in the ModuleController class. You can obtain a reference to the Shell's main menu using the following code.
    WorkItem.UIExtensionSites[UIExtensionSiteNames.MainMenu]
    
    

    For more information, see Showing UIElements.

  • Add new items to the tool strip in the shell in the module controller. To do this, implement the ExtendToolStrip method in the ModuleController class. You can obtain a reference to the Shell's main toolbar using the following code.
    WorkItem.UIExtensionSites[UIExtensionSiteNames.MainToolbar]
    
    
  • Add views with presenters. You can add views using the Add View (with Presenter) recipe. For information about how to run the recipe, see How to: Add a View with a Presenter.
  • Create service agents to consume Web services. Disconnected service agents add offline capabilities to your Web service proxies. This is useful for occasionally connected applications.

    For information about how to create a disconnected service agent, see How to: Create a Disconnected Service Agent.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.