DSInternals/Src/DSInternals.SAM/Wrappers/SamObject.cs
2015-12-26 23:44:43 +01:00

42 lines
849 B
C#

using DSInternals.SAM.Interop;
using System;
using System.Security;
namespace DSInternals.SAM
{
public abstract class SamObject : IDisposable
{
protected SafeSamHandle Handle
{
get;
set;
}
protected SamObject(SafeSamHandle handle)
{
this.Handle = handle;
}
public void ReleaseHandle()
{
if (this.Handle != null)
{
this.Handle.Dispose();
this.Handle = null;
}
}
public void Dispose()
{
Dispose(true);
System.GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if(disposing)
{
this.ReleaseHandle();
}
}
}
}