mirror of
https://github.com/MistWeatherMedia/i2ME.git
synced 2026-11-28 14:20:00 -08:00
58 lines
1.2 KiB
C#
58 lines
1.2 KiB
C#
using System;
|
|
|
|
namespace TWC.Util
|
|
{
|
|
public class Disposable : IDisposable
|
|
{
|
|
private bool disposed;
|
|
|
|
~Disposable()
|
|
{
|
|
this.DoDispose(false);
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
this.DoDispose(true);
|
|
GC.SuppressFinalize((object)this);
|
|
}
|
|
|
|
private bool Disposed
|
|
{
|
|
get
|
|
{
|
|
return this.disposed;
|
|
}
|
|
}
|
|
|
|
public void AssertNotDisposed()
|
|
{
|
|
if (this.disposed)
|
|
throw new ObjectDisposedException((string)null);
|
|
}
|
|
|
|
protected virtual void Dispose(bool disposing)
|
|
{
|
|
if (disposing)
|
|
this.DisposeManaged();
|
|
this.DisposeUnmanaged();
|
|
}
|
|
|
|
protected virtual void DisposeManaged()
|
|
{
|
|
}
|
|
|
|
protected virtual void DisposeUnmanaged()
|
|
{
|
|
}
|
|
|
|
private void DoDispose(bool disposing)
|
|
{
|
|
if (this.disposed)
|
|
return;
|
|
this.Dispose(disposing);
|
|
this.disposed = true;
|
|
}
|
|
}
|
|
}
|