CVB.Net 15.0
ScopedState< TState > Class Template Referencesealed

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

Public Member Functions

 ScopedState (Ref< TState > store, TState scopedState)
 Ctor.
 
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
ScopedState(Ref< TState > store, TState scopedState)
Ctor.
Definition ScopedState.cs:30
Template Parameters
TStateMust be a value type.
Type Constraints
TState :struct 

Member Function 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.