PeanutButter
Loading...
Searching...
No Matches
PeanutButter.Utils.AutoResetter< T > Class Template 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. This is the variant of AutoResetter where: More...

Inheritance diagram for PeanutButter.Utils.AutoResetter< T >:

Public Member Functions

 AutoResetter (Func< T > start, Action< T > end)
 Constructs a new AutoResetter, runs the start Func and stores the result.
void Dispose ()

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. This is the variant of AutoResetter where:

  1. The start Func returns a value
  2. Upon disposal, the end action is called with the value from (1)
Template Parameters
TType of value which is passed to the start and end actions

Member Function Documentation

◆ AutoResetter()

PeanutButter.Utils.AutoResetter< T >.AutoResetter ( Func< T > start,
Action< T > end )

Constructs a new AutoResetter, runs the start Func and stores the result.

Parameters
startCode to run at construction
endCode to run at disposal; will receive the result provided from the start Func

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