| | 1 | | using System; |
| | 2 | | using SharpHoundRPC.Handles; |
| | 3 | |
|
| | 4 | | namespace SharpHoundRPC.Wrappers |
| | 5 | | { |
| | 6 | | public class SAMBase : IDisposable |
| | 7 | | { |
| | 8 | | protected SAMHandle Handle; |
| | 9 | |
|
| 0 | 10 | | protected SAMBase(SAMHandle handle) |
| 0 | 11 | | { |
| 0 | 12 | | Handle = handle; |
| 0 | 13 | | } |
| | 14 | |
|
| | 15 | | public void Dispose() |
| 0 | 16 | | { |
| 0 | 17 | | Dispose(true); |
| 0 | 18 | | } |
| | 19 | |
|
| | 20 | | protected virtual void Dispose(bool disposing) |
| 0 | 21 | | { |
| 0 | 22 | | if (disposing) ReleaseHandle(); |
| 0 | 23 | | } |
| | 24 | |
|
| | 25 | | protected virtual void ReleaseHandle() |
| 0 | 26 | | { |
| 0 | 27 | | Handle?.Dispose(); |
| 0 | 28 | | Handle = null; |
| | 29 | | //Call suppressfinalize to prevent finalization, since we've already cleaned up our own stuff |
| 0 | 30 | | GC.SuppressFinalize(this); |
| 0 | 31 | | } |
| | 32 | | } |
| | 33 | | } |