// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using System;
namespace Microsoft.Research.SEAL.Tools
{
///
/// Class that implements the Disposable pattern
///
public class DisposableObject : IDisposable
{
///
/// Derived classes should override this method to release managed resources.
///
protected virtual void DisposeManagedResources()
{
}
///
/// Derived classes should override this method to release native resources.
///
protected virtual void DisposeNativeResources()
{
}
///
/// Whether this object is disposed
///
public bool IsDisposed
{
get
{
return disposedValue;
}
}
#region IDisposable Support
private bool disposedValue = false; // To detect redundant calls
private void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
DisposeManagedResources();
}
DisposeNativeResources();
disposedValue = true;
}
}
///
/// DisposableObject destructor
///
~DisposableObject()
{
// Do not change this code. Put cleanup code in Dispose(bool disposing) above.
Dispose(false);
}
///
/// This code is added to correctly implement the disposable pattern.
///
public void Dispose()
{
// Do not change this code. Put cleanup code in Dispose(bool disposing) above.
Dispose(true);
GC.SuppressFinalize(this);
}
#endregion
}
}