r2mods/ilspy_dump/ror2_csproj/RoR2.Scripts.Utility/ScopedReset.cs

23 lines
346 B
C#
Raw Normal View History

2024-10-04 07:26:37 +00:00
using System;
namespace RoR2.Scripts.Utility;
internal class ScopedReset<T> : IDisposable
{
private T originalValue;
private Action<T> _setter;
public ScopedReset(Func<T> getter, Action<T> setter, T tempVal)
{
originalValue = getter();
setter(tempVal);
_setter = setter;
}
public void Dispose()
{
_setter(originalValue);
}
}