blob: 60006c51b2c3a9d9ce3877e3754c9645da03318c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
using System;
namespace StardewModdingAPI.Framework.StateTracking.FieldWatchers
{
/// <summary>The base implementation for a disposable watcher.</summary>
internal abstract class BaseDisposableWatcher : IDisposable
{
/*********
** Fields
*********/
/// <summary>Whether the watcher has been disposed.</summary>
protected bool IsDisposed { get; private set; }
/*********
** Public methods
*********/
/// <summary>Stop watching the field and release all references.</summary>
public virtual void Dispose()
{
this.IsDisposed = true;
}
/*********
** Protected methods
*********/
/// <summary>Throw an exception if the watcher is disposed.</summary>
/// <exception cref="ObjectDisposedException">The watcher is disposed.</exception>
protected void AssertNotDisposed()
{
if (this.IsDisposed)
throw new ObjectDisposedException(this.GetType().Name);
}
}
}
|