-
Notifications
You must be signed in to change notification settings - Fork 64
/
WebDAVDisposableBase.cs
41 lines (37 loc) · 1.44 KB
/
WebDAVDisposableBase.cs
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
37
38
39
40
41
using System;
namespace WebDAVSharp.Server
{
/// <summary>
/// This abstract base class implements the <see cref="IDisposable" /> pattern in a reusable way.
/// </summary>
public abstract class WebDavDisposableBase : IDisposable
{
private bool _isDisposed;
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
_isDisposed = true;
}
/// <summary>
/// This method will ensure that the object has not been disposed of through a call
/// to
/// <see cref="Dispose()" />, and if it has, it will throw
/// <see cref="ObjectDisposedException" />
/// </summary>
/// <exception cref="System.ObjectDisposedException">The object has been disposed of.</exception>
protected void EnsureNotDisposed()
{
if (_isDisposed)
throw new ObjectDisposedException(GetType().FullName);
}
/// <summary>
/// Releases unmanaged and - optionally - managed resources
/// </summary>
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
protected abstract void Dispose(bool disposing);
}
}