Debugging using code

From FlexRule Wiki
Jump to: navigation, search

Using Events

The other way of debugging your rules is by using some events and internal methods that are provided by all engines. All of the following engines derive from a base class called ActiveElementEngine that provides some base events and methods to enable you to track the execution of rules:

  1. Procedural
  2. Validation
  3. Flow
  4. Decision
  5. Workflow

The following events give you the ability to monitor the execution of rules:

  1. /// <summary>
  2. /// When element is executing
  3. /// </summary>
  4. public event EventHandler<ActiveElementExecutionEventArgs> ActiveElementExecuting;
  6. /// <summary>
  7. /// When element execution is finished
  8. /// </summary>
  9. public event EventHandler<ActiveElementExecutionEventArgs> ActiveElementExecuted;
  11. /// <summary>
  12. /// When executor passes an element
  13. /// </summary>
  14. public event EventHandler<ActiveElementExecutionEventArgs> ActiveElementItemOutOfScope;
  16. /// <summary>
  17. /// When element is reached
  18. /// </summary>
  19. public event EventHandler<ActiveElementExecutionEventArgs> ActiveElementItemTracing;

If you are writing a unit test, console application, or any sort of sample application that consumes your rules, then you can handle these events and start logging and debugging execution by putting a break point on these event handlers.

Also, the other way of putting a break point inside your rules is using the 'System.Diagnostics.Debugger.Break()' method. You can simply use Using to import these into your rules and call the 'Break' method to attach your rules to the debugger when required.

  1. <Declaration>
  2.     <Using path="System.Diagnostics.Debugger"/>
  3. </Declaration>

Next sections

  1. Introduction to debugging
  2. Debugging using Designer
  3. Debugging using code
  4. Debugging in Visual Studio
  5. Inspection Windows
    1. Parameters window
    2. Watch window
  6. Debugging Workflow