From 27f4f56d2d7491e29b9e9339b0632c55422003a2 Mon Sep 17 00:00:00 2001 From: Jeremy Sinclair <4016293+snickler@users.noreply.github.com> Date: Wed, 16 Aug 2023 13:19:51 -0400 Subject: [PATCH] Switching to ObjectDisposedException.ThrowIf --- src/modules/PowerOCR/PowerOCR/Helpers/WrappingStream.cs | 5 +---- src/modules/previewpane/common/Utilities/ReadonlyStream.cs | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/modules/PowerOCR/PowerOCR/Helpers/WrappingStream.cs b/src/modules/PowerOCR/PowerOCR/Helpers/WrappingStream.cs index fc49112ef6..5b952d1f73 100644 --- a/src/modules/PowerOCR/PowerOCR/Helpers/WrappingStream.cs +++ b/src/modules/PowerOCR/PowerOCR/Helpers/WrappingStream.cs @@ -220,9 +220,6 @@ public class WrappingStream : Stream private void ThrowIfDisposed() { // throws an ObjectDisposedException if this object has been disposed - if (_streamBase == null) - { - throw new ObjectDisposedException(GetType().Name); - } + ObjectDisposedException.ThrowIf(_streamBase == null, this); } } diff --git a/src/modules/previewpane/common/Utilities/ReadonlyStream.cs b/src/modules/previewpane/common/Utilities/ReadonlyStream.cs index 82959a38c2..bb066df72d 100644 --- a/src/modules/previewpane/common/Utilities/ReadonlyStream.cs +++ b/src/modules/previewpane/common/Utilities/ReadonlyStream.cs @@ -240,10 +240,7 @@ namespace Common.Utilities private void CheckDisposed() { - if (_stream == null) - { - throw new ObjectDisposedException(nameof(ReadonlyStream)); - } + ObjectDisposedException.ThrowIf(_stream == null, this); } } }