using AsyncAwaitBestPractices; using StabilityMatrix.Core.Services; namespace StabilityMatrix.Core.Models.Settings; /// /// Transaction object which saves settings manager changes when disposed. /// public class SettingsTransaction(ISettingsManager settingsManager, Action onCommit, Func onCommitAsync) : IDisposable, IAsyncDisposable { public Settings Settings => settingsManager.Settings; public void Dispose() { onCommit(); GC.SuppressFinalize(this); } public async ValueTask DisposeAsync() { await onCommitAsync().ConfigureAwait(false); GC.SuppressFinalize(this); } }