/// <summary> /// Calls <see cref="IDisposable.Dispose"/> on an <see cref="IDisposable"/> object when not null. /// </summary> /// <param name="disposable"></param> public static void SafeDispose(this IDisposable disposable) { disposable.DoWhen(d => d.Dispose()); }