mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-20 11:45:43 +08:00
Fix broken unit tests.
This commit is contained in:
@@ -2,32 +2,20 @@
|
||||
|
||||
namespace MQTTnet.Internal
|
||||
{
|
||||
public class Disposable : IDisposable
|
||||
public abstract class Disposable : IDisposable
|
||||
{
|
||||
protected bool IsDisposed => _isDisposed;
|
||||
protected bool IsDisposed { get; private set; } = false;
|
||||
|
||||
protected void ThrowIfDisposed()
|
||||
{
|
||||
if (_isDisposed)
|
||||
if (IsDisposed)
|
||||
{
|
||||
throw new ObjectDisposedException(GetType().Name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region IDisposable Support
|
||||
|
||||
private bool _isDisposed = false; // To detect redundant calls
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// TODO: dispose managed state (managed objects).
|
||||
}
|
||||
|
||||
// TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
|
||||
// TODO: set large fields to null.
|
||||
}
|
||||
|
||||
// TODO: override a finalizer only if Dispose(bool disposing) above has code to free unmanaged resources.
|
||||
@@ -40,18 +28,17 @@ namespace MQTTnet.Internal
|
||||
// This code added to correctly implement the disposable pattern.
|
||||
public void Dispose()
|
||||
{
|
||||
if (_isDisposed)
|
||||
// Do not change this code. Put cleanup code in Dispose(bool disposing) above.
|
||||
|
||||
if (IsDisposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_isDisposed = true;
|
||||
IsDisposed = true;
|
||||
|
||||
// Do not change this code. Put cleanup code in Dispose(bool disposing) above.
|
||||
Dispose(true);
|
||||
// TODO: uncomment the following line if the finalizer is overridden above.
|
||||
// GC.SuppressFinalize(this);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user