using System; namespace StardewModdingAPI.Framework.StateTracking.FieldWatchers { /// The base implementation for a disposable watcher. internal abstract class BaseDisposableWatcher : IDisposable { /********* ** Fields *********/ /// Whether the watcher has been disposed. protected bool IsDisposed { get; private set; } /********* ** Public methods *********/ /// Stop watching the field and release all references. public virtual void Dispose() { this.IsDisposed = true; } /********* ** Protected methods *********/ /// Throw an exception if the watcher is disposed. /// The watcher is disposed. protected void AssertNotDisposed() { if (this.IsDisposed) throw new ObjectDisposedException(this.GetType().Name); } } }