/// /// A class which can be disposed. /// public class Disposable : IDisposable { /// /// The action to perform on dispose. /// private readonly Action onDispose; /// /// Initializes a new dispoable. /// /// The action to perform. private Disposable(Action onDispose) { this.onDispose = onDispose; } /// /// Creates a disposable class. /// /// The dispose action. /// A disposable. public static IDisposable Create(Action onDispose) { return new Disposable(onDispose); } /// /// Dispose. /// public void Dispose() { onDispose(); } }