Logic Controllers. Learn More

This topic describes some peculiarities of working Logic Controllers.

  • Inheritance
  • Access Events and Properties
  • Diagnostic

At the same time, it is required to customize a Logic Controller provided by the some module. You can access its properties, handle events or inherit and override virtual methods. These same approaches apply to both standard XAF Controller, see Customize Controllers and Actions. The specifics that can occur are described below.

Inheritance

Before inherit from the Logic Controller, it is recommended to examine Customize Controllers and Actions. Inherit From a Controller paragraph. The application utilizes only Logic Controllers that are finite in the inheritance hierarchy, i.e. if some class is registered as a Logic Controller, its ancestor will not function as a Logic Controller. A typical use case is to implement heirs in target-specific modules.

The figure below demonstrates a statement above: The Web application uses WebManagedOperationDeleteLogicController and Win app uses WinManagedOperationDeleteLogicController, ManagedOperationDeleteLogicController instance will not to be created.

Access Events and Properties

Before customize the Logic Controller, it is recommended to examine Customize Controllers and Actions topic. The Active property controls the operating state of the Logic Controller, by analogy with the View Controller. To get Logic Controller from the ViewController or Frame, use the extension method GetLogicController<T>, where T is the accompanied type.

Example of access from View Controller:

  • c#
  • VB

using Xafari.BC;
public class MyController : ViewController
{
  protected override void OnFrameAssigned()
  {
    base.OnFrameAssigned();
    // ...
    var logicController = this.Xafari().BC().GetLogicController<EmployeeLogicController>();
    if (logicController != null)
    {
      logicController.Active["CustomDeactivation"] = false;
    }
    // ...
  }
}

Imports Xafari.BC
Public Class MyController
  Inherits ViewController
  Protected Overrides Sub OnFrameAssigned()
    MyBase.OnFrameAssigned()
    ' ...
    Dim logicController = Me.Xafari().BC().GetLogicController(Of EmployeeLogicController)()
    If logicController IsNot Nothing Then
      logicController.Active("CustomDeactivation") = False
    End If
    ' ...
  End Sub
End Class

Example of access from Frame:

  • c#
  • VB

using Xafari.BC;
public class MyController : ViewController
{
  protected override void OnFrameAssigned()
  {
    base.OnFrameAssigned();
    // ...
    var logicController = Frame.Xafari().GetLogicController<EmployeeLogicController>();
    if (logicController != null)
    {
      logicController.Active["CustomDeactivation"] = false;
    }
    // ...
  }
}

Imports Xafari.BC
Public Class MyController
  Inherits ViewController
  Protected Overrides Sub OnFrameAssigned()
    MyBase.OnFrameAssigned()
    ' ...
    Dim logicController = Frame.Xafari().GetLogicController(Of EmployeeLogicController)()
    If logicController IsNot Nothing Then
      logicController.Active("CustomDeactivation") = False
    End If
    ' ...
  End Sub
End Class

Diagnostic

Diagnostic|View Info Action allows to obtain information about the Logic Controllers in the diagnostics window, see <LogicControllers> section of the "Diagnostic Info Object" window:

ViewController 2 LogicController item displays a list of all View Controllers of the the current View, which can be implemented using Logic Controller.