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.
Implements
Inherited Members
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()