PeanutButter
Loading...
Searching...
No Matches
PeanutButter.Utils.Steps Class Reference

Provides a mechanism to surround an action with a pre-action and post-action. More...

Public Member Functions

void Run (Action before, Action activity, Action< Exception > after)
 Runs the provided steps in order.
void Run (Action before, Action activity, Func< Exception, ErrorHandlerResult > after)
 Runs the three provided actions in order, providing any exception thrown by the first two actions to the final one which can decide on whether the error is fatal or not.
async Task RunAsync (Func< Task > before, Func< Task > activity, Func< Exception, Task > after)
 Runs the provided steps in order.
async Task RunAsync (Func< Task > before, Func< Task > activity, Func< Exception, Task< ErrorHandlerResult > > after)
 Runs the three provided actions in order, providing any exception thrown by the first two actions to the final one which can return true to suppress the error or false to.

Detailed Description

Provides a mechanism to surround an action with a pre-action and post-action.

Member Function Documentation

◆ Run() [1/2]

void PeanutButter.Utils.Steps.Run ( Action before,
Action activity,
Action< Exception > after )

Runs the provided steps in order.

  • before
  • activity
  • after
  • after is supplied any exception thrown by the activity - if the activity completes without error, after will be called with null
  • errors in the before and after actions are not handled for you
Parameters
before
activity
after

◆ Run() [2/2]

void PeanutButter.Utils.Steps.Run ( Action before,
Action activity,
Func< Exception, ErrorHandlerResult > after )

Runs the three provided actions in order, providing any exception thrown by the first two actions to the final one which can decide on whether the error is fatal or not.

  • after is supplied any exception thrown by the activity - if the activity completes without error, after will be called with null.
  • after must direct the Steps what to do next: NoError: do nothing (there was no error) Rethrow: rethrow the error from the original scope Suppress: suppress the error
  • errors in the before and after actions are not handled for you
Parameters
before
activity
after
Exceptions
NotImplementedException

◆ RunAsync() [1/2]

async Task PeanutButter.Utils.Steps.RunAsync ( Func< Task > before,
Func< Task > activity,
Func< Exception, Task > after )

Runs the provided steps in order.

  • before
  • activity
  • after
  • after is supplied any exception thrown by the activity - if the activity completes without error, after will be called with null
  • errors in the before and after actions are not handled for you
Parameters
before
activity
after

◆ RunAsync() [2/2]

async Task PeanutButter.Utils.Steps.RunAsync ( Func< Task > before,
Func< Task > activity,
Func< Exception, Task< ErrorHandlerResult > > after )

Runs the three provided actions in order, providing any exception thrown by the first two actions to the final one which can return true to suppress the error or false to.

Parameters
before
activity
after
Exceptions
NotImplementedException

The documentation for this class was generated from the following file:
  • source/Utils/PeanutButter.Utils/Steps.cs