namespace View_by_Distance.FaceRecognitionDotNet;
///
/// Represents a class which has managed or unmanaged resources.
///
public abstract class DisposableObject : IDisposable
{
#region Properties
///
/// Gets a value indicating whether this instance has been disposed.
///
/// true if this instance has been disposed; otherwise, false.
public bool IsDisposed
{
get;
private set;
}
#endregion
#region Methods
///
/// If this object is disposed, then is thrown.
///
public void ThrowIfDisposed() =>
ObjectDisposedException.ThrowIf(IsDisposed, this);
internal void ThrowIfDisposed(string objectName)
{
#pragma warning disable CA1513
if (IsDisposed)
throw new ObjectDisposedException(objectName);
#pragma warning restore CA1513
}
#region Overrides
///
/// Releases all managed resources.
///
protected virtual void DisposeManaged()
{
}
///
/// Releases all unmanaged resources.
///
protected virtual void DisposeUnmanaged()
{
}
#endregion
#endregion
#region IDisposable Members
///
/// Releases all resources used by this .
///
public void Dispose()
{
GC.SuppressFinalize(this);
Dispose(true);
}
///
/// Releases all resources used by this .
///
/// Indicate value whether method was called.
private void Dispose(bool disposing)
{
if (IsDisposed)
{
return;
}
IsDisposed = true;
if (disposing)
DisposeManaged();
DisposeUnmanaged();
}
#endregion
}