|
PeanutButter
|
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...
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 () |
| AutoResetter (Func< T > start, Action< T > end) | |
| Constructs a new AutoResetter, runs the start Func and stores the result. | |
| 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. | |
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.
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:
| T | Type of value which is passed to the start and end actions |
| PeanutButter.Utils.AutoResetter< T >.AutoResetter | ( | Action | constructionAction, |
| Action | disposalAction | ||
| ) |
Constructs a new AutoResetter and immediately runs the constructionAction.
| constructionAction | Action to run at construction time |
| disposalAction | Action to run at disposal time |
| PeanutButter.Utils.AutoResetter< T >.AutoResetter | ( | Action | disposalAction | ) |
Constructs a new AutoResetter with the disposal action set and no construction action.
| disposalAction |
| PeanutButter.Utils.AutoResetter< T >.AutoResetter | ( | Func< T > | start, |
| Action< T > | end | ||
| ) |
Constructs a new AutoResetter, runs the start Func and stores the result.
| start | Code to run at construction |
| end | Code to run at disposal; will receive the result provided from the start Func |
|
static |
Convenience to create an AutoResetter without new or having to care about whether you're using the action or func variant.
| onStart | |
| onDisposed |
|
static |
Convenience to create an AutoResetter without new or having to care about whether you're using the action or func variant.
| onStart | |
| onDisposed |