// // Licensed under the MIT License. See LICENSE file in the project root for full license information. // namespace MUnique.OpenMU.GameLogic; /// /// Base class for a disposable class. /// public class Disposable : IDisposable { /// /// Finalizes an instance of the class. /// ~Disposable() { this.Dispose(false); } /// /// Gets a value indicating whether this instance is disposed. /// /// /// true if this instance is disposed; otherwise, false. /// public bool IsDisposed { get; private set; } /// /// Gets a value indicating whether this instance is disposing. /// /// /// true if this instance is disposing; otherwise, false. /// public bool IsDisposing { get; private set; } /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// public void Dispose() { if (!this.IsDisposed && !this.IsDisposing) { this.IsDisposing = true; try { this.Dispose(true); this.IsDisposed = true; } finally { this.IsDisposing = false; } } GC.SuppressFinalize(this); } /// /// Releases unmanaged and - optionally - managed resources. /// /// true to release both managed and unmanaged resources; false to release only unmanaged resources. protected virtual void Dispose(bool disposing) { } }