/// <summary> /// Registers an IDisposable with the <see cref="Disposables"/> instance. /// </summary> public static T DisposeWith <T>(this T value, Disposables disposables) where T : IDisposable => disposables.Register(value);
/// <summary> /// Registers an object with the <see cref="Disposables" /> instance with custom disposal logic. /// </summary> public static T DisposeWith <T>(this T value, Disposables disposables, Action <T> onDispose) => disposables.Register(value.AsDisposable(onDispose));