CVB.Net 14.0
ScopedState< TState > Class Template Reference

Simple object for writing RAII-like scoped states (see example). More...

Inherits IDisposable.

Public Member Functions

 ScopedState (Ref< TState > store, TState scopedState)
 Ctor. More...
 
void Dispose ()
 Cleanup - restore the flag's original value.
 

Detailed Description

Simple object for writing RAII-like scoped states (see example).

bool flag = false;
...
using (ScopedState f(new Ref(flag), true))
{
// in here, flag will be true
}
// upon leaving, flag will revert to false
Class to store a reference to a value type in.
Definition: Ref.cs:10
Simple object for writing RAII-like scoped states (see example).
Definition: ScopedState.cs:22
Template Parameters
TStateMust be a value type.
Type Constraints
TState :struct 

Constructor & Destructor Documentation

◆ ScopedState()

ScopedState ( Ref< TState >  store,
TState  scopedState 
)

Ctor.

Parameters
storeReference to the value type that contains the flag to be altered in the scope.
scopedStateState the flag should assume inside the scope.