Modules are deployment units in composite application. Developers can separate areas of their application into different modules to be able to deploy them to different users or applications. In Scab Modules are represented by Elisy.Scab.Module inherited classes.

To create a module

  1. Create a new Silverlight Class Library
  2. Create a new public class in the library project. Inherit it from Elisy.Scab.Module.
  3. Declare any public properties that can be used for module configuration.
  4. Override ApplicationStarting method to register objects (services, presenters etc.) or create a shell. Scab application calls this method before any Application Startup event handlers.
  5. Override ApplicationStarted method to create visual elements on the shell. Scab application calls this method after creating the shell in Application Startup event handler.

To load a module

  1. Declare in the App.xaml xmlns referring to module assembly and namespace. For example xmlns:shellmodule="clr-namespace:ShellModule;assembly=ShellModule".
  2. In Application.Resources list the appropriate modules to load as shown in the following
    <Application.Resources>
        <modules:Module x:Key="Module">
            <modules:Module x:Key="SubModule" ServiceName="SubService"/>
        </modules:Module>
    </Application.Resources>
    Please note you can declare them hierarchically with custom parameters declared in module classes. In some cases App.xaml can be excluded from assembly and included into Xap. It allows application to be configured on the server side.

Example

Modules.zip (104.16 kb)

The following example includes CompositeApplication application and two module assemblies (ShellModule and UserControlModule). ShellModule creates the Shell user control in ApplicationStarting overrided method. UserControlModule declares parameter Text that can be configured in the App.xaml of the executing application. UserControlModule adds user control to the shell in overridden ApplicationStarted method showing Text value in StackPanel.

App.xaml file in application assembly refers to both module assemblies by xmlns and specifies them in Application.Resources. The UserControlModule will be loaded with Text="Module Parameter" parameter.

Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5