PkmnLibSharp/PkmnLibSharp/PointerWrapper.cs

24 lines
487 B
C#
Raw Normal View History

2020-05-02 17:54:07 +00:00
using System;
namespace PkmnLibSharp
{
public abstract class PointerWrapper : IDisposable
{
internal readonly IntPtr Ptr;
2020-05-02 18:30:33 +00:00
private bool _isDeleted = false;
2020-05-02 17:54:07 +00:00
protected PointerWrapper(IntPtr ptr)
{
Ptr = ptr;
}
internal abstract void DeletePtr();
public virtual void Dispose()
{
if (_isDeleted)
return;
DeletePtr();
_isDeleted = true;
}
}
}