Generation Gap Pattern Support

To allow developers to extend generated code and keep modifications, Sybase supports a generation gap pattern. This pattern makes use of a C# partial classes to provide customization. For certain logic-related classes, a “protected virtual” method lets you override the method with your own implementation.

An application consists of both generated code and customized code.


Customizing DAD Code

Following is an example of the FormCreateCustomerController class:

/// <summary>
/// The Base class of FormCreateCustomerController
/// </summary>
internal abstract class FormCreateCustomerControllerBase :
  ControllerBase
{
  public FormCreateCustomerControllerBase(IFormPart form)
    : base(form)
  {
  }
  // button (Submit) click event handler
  internal virtual void
    SubmitButton_Handler(FormsManagerDataObject dataObject)
  {
    ....
  }
}

/// <summary>
/// The Controller class of Form FormCreateCustomer
/// </summary>
internal partial class FormCreateCustomerController :
  FormCreateCustomerControllerBase
{
  public FormCreateCustomerController(IFormPart form)
  : base(form)
  {
  }
}
You may want to customize the business logic. For example, if you want to customize the Submit action, you could do the following:
  • Create a MyFormCreateCustomerController.cs class in the CustomizedCode folder
  • Change the default code to:
internal partial class FormCreateCustomerController
{
  internal override void SubmitButton_Handler(Sybase.UnwiredPlatform.Windows.Forms.FormsManagerDataObject   dataObject)
  {
     // Add your custom actions here
     MessageBox.Show("Before Submit!");

     // Perform the default action
     base.SubmitButton_Handler(dataObject);
  }
}