using System.Diagnostics.CodeAnalysis; namespace Yi.Framework.Infrastructure.Utils { public class DisposeAction : IDisposable { private readonly Action _action; private readonly T _parameter; /// /// Creates a new object. /// /// Action to be executed when this object is disposed. /// The parameter of the action. public DisposeAction(Action action, T parameter) { _action = action; _parameter = parameter; } public void Dispose() { _action(_parameter); } } }