forked from WebDAVSharp/WebDAVSharp.Server
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWebDAVDisposableBase.cs
More file actions
56 lines (46 loc) · 1.66 KB
/
WebDAVDisposableBase.cs
File metadata and controls
56 lines (46 loc) · 1.66 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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
{
#region Properties
private bool _isDisposed;
#endregion
#region Abstract Functions
/// <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);
#endregion
#region Functions
/// <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);
}
#endregion
}
}