Window Handling Object

Never call Override-Methods, because:

  • these methods are in general called automatically from the framework, as a result of an action

  • they are usually part of a sequence of actions (Example: OnSave() is called after OnPreSave() – if the latter returned>0 – and if OnSave() returns>0, OnPostSave() is called)

  • these methods are the equivalent of "event handlers", which should never be called directly; if the code sequence contained in the override method is needed, a common method should be written and called every time it is needed

  • whenever an event has to be called, it means that the functionality behind the event should be extracted into a method; in this case, the method can be called from the event itself, as well as anywhere else, explicitly.

Examples:

  • call WHO-method in override Method

public override void OnNew(UIElement sourceControl)
{
    if (sourceControl == dgMaterial)
    {
        NewMaterial();
    }
}
  • call BusinessObject-method from WHO-method

public virtual void NewMaterial()
{
    var material = BusObj.NewMatRow();
    if (material == null) return;
}

Order of execution: Event -> WHO-method -> BusObj.

Last updated