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

Provides a mechanism to run code on construction and disposal, irrespective of exception handling Use this, for example, to set up and tear down state required for a test – your constructionAction is called immediately upon construction and the using() pattern guarantees that your disposalAction is called at disposal, even if your test fails. More...

Inheritance diagram for PeanutButter.Utils.AutoResetter:

Public Member Functions

 AutoResetter (Action constructionAction, Action disposalAction)
 Constructs a new AutoResetter and immediately runs the constructionAction.
 AutoResetter (Action disposalAction)
 Constructs a new AutoResetter with the disposal action set and no construction action.
void Dispose ()

Static Public Member Functions

static AutoResetter Create (Action onStart, Action onDisposed)
 Convenience to create an AutoResetter without new or having to care about whether you're using the action or func variant.
static AutoResetter< T > Create< T > (Func< T > onStart, Action< T > onDisposed)
 Convenience to create an AutoResetter without new or having to care about whether you're using the action or func variant.

Detailed Description

Provides a mechanism to run code on construction and disposal, irrespective of exception handling Use this, for example, to set up and tear down state required for a test – your constructionAction is called immediately upon construction and the using() pattern guarantees that your disposalAction is called at disposal, even if your test fails.

Constructor & Destructor Documentation

◆ AutoResetter() [1/2]

PeanutButter.Utils.AutoResetter.AutoResetter ( Action constructionAction,
Action disposalAction )

Constructs a new AutoResetter and immediately runs the constructionAction.

Parameters
constructionActionAction to run at construction time
disposalActionAction to run at disposal time

◆ AutoResetter() [2/2]

PeanutButter.Utils.AutoResetter.AutoResetter ( Action disposalAction)

Constructs a new AutoResetter with the disposal action set and no construction action.

Parameters
disposalAction

Member Function Documentation

◆ Create()

AutoResetter PeanutButter.Utils.AutoResetter.Create ( Action onStart,
Action onDisposed )
static

Convenience to create an AutoResetter without new or having to care about whether you're using the action or func variant.

Parameters
onStart
onDisposed
Returns

◆ Create< T >()

AutoResetter< T > PeanutButter.Utils.AutoResetter.Create< T > ( Func< T > onStart,
Action< T > onDisposed )
static

Convenience to create an AutoResetter without new or having to care about whether you're using the action or func variant.

Parameters
onStart
onDisposed
Returns

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