ScopedStateTState Class

CVB.Net Documentation
Simple object for writing RAII-like scoped states (see example).
Inheritance Hierarchy

SystemObject
  Stemmer.CvbScopedStateTState

Namespace:  Stemmer.Cvb
Assembly:  Stemmer.Cvb (in Stemmer.Cvb.dll) Version: 14.0.0.0
Syntax

public sealed class ScopedState<TState> : IDisposable
where TState : struct, new()

Type Parameters

TState
Must be a value type.

The ScopedStateTState type exposes the following members.

Constructors

  NameDescription
Public methodScopedStateTState
Ctor.
Top
Methods

  NameDescription
Public methodDispose
Cleanup - restore the flag's original value.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Examples

bool flag = false;
...
using (ScopedState f(new Ref(flag), true))
{
  // in here, flag will be true
}
// upon leaving, flag will revert to false
See Also

Reference