diff --git a/src/ImageSharp/Image.cs b/src/ImageSharp/Image.cs
index c07c7fe83..3aa30063d 100644
--- a/src/ImageSharp/Image.cs
+++ b/src/ImageSharp/Image.cs
@@ -19,6 +19,8 @@ namespace SixLabors.ImageSharp
///
public abstract partial class Image : IImage, IConfigurationProvider
{
+ private bool isDisposed;
+
private Size size;
private readonly Configuration configuration;
@@ -78,7 +80,17 @@ namespace SixLabors.ImageSharp
Configuration IConfigurationProvider.Configuration => this.configuration;
///
- public void Dispose() => this.Dispose(true);
+ public void Dispose()
+ {
+ if (this.isDisposed)
+ {
+ return;
+ }
+
+ this.Dispose(true);
+
+ this.isDisposed = true;
+ }
///
/// Saves the image to the given stream using the given image encoder.
@@ -144,7 +156,13 @@ namespace SixLabors.ImageSharp
///
/// Throws if the image is disposed.
///
- internal abstract void EnsureNotDisposed();
+ internal void EnsureNotDisposed()
+ {
+ if (this.isDisposed)
+ {
+ throw new ObjectDisposedException("Trying to execute an operation on a disposed image.");
+ }
+ }
///
/// Accepts a .
diff --git a/src/ImageSharp/Image{TPixel}.cs b/src/ImageSharp/Image{TPixel}.cs
index 9c32a2c31..c43643052 100644
--- a/src/ImageSharp/Image{TPixel}.cs
+++ b/src/ImageSharp/Image{TPixel}.cs
@@ -23,8 +23,6 @@ namespace SixLabors.ImageSharp
public sealed class Image : Image
where TPixel : unmanaged, IPixel
{
- private bool isDisposed;
-
private ImageFrameCollection frames;
///
@@ -272,26 +270,10 @@ namespace SixLabors.ImageSharp
///
protected override void Dispose(bool disposing)
{
- if (this.isDisposed)
- {
- return;
- }
-
if (disposing)
{
this.frames.Dispose();
}
-
- this.isDisposed = true;
- }
-
- ///
- internal override void EnsureNotDisposed()
- {
- if (this.isDisposed)
- {
- throw new ObjectDisposedException("Trying to execute an operation on a disposed image.");
- }
}
///