Show / Hide Table of Contents

Class TemporaryValue<T>

Temporarily sets a value and restores the original when disposed. Use within a using block to ensure the original value is restored.

Inheritance
object
TemporaryValue<T>
Implements
IDisposable
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
Namespace: SuperOffice.Util
Assembly: SoCore.dll
Syntax
public sealed class TemporaryValue<T> : IDisposable
Type Parameters
Name Description
T

The type of the value being temporarily changed.

Constructors

TemporaryValue(Func<T>, Action<T>, T)

Captures the current value via getter, then applies temporaryValue using setter.

Declaration
public TemporaryValue(Func<T> getter, Action<T> setter, T temporaryValue)
Parameters
Type Name Description
Func<T> getter

A function that returns the current value.

Action<T> setter

An action that sets the value.

T temporaryValue

The temporary value to apply until this instance is disposed.

Methods

Dispose()

Restores the original value that was captured at construction time.

Declaration
public void Dispose()

Implements

IDisposable

Extension Methods

EnumUtil.MapEnums<From, To>(From)
Converters.MapEnums<From, To>(From)
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top