Added SafeAllocatedMemoryHandleBase.GetBytes() and pulled SafeMemoryHandle.Locked from IMemoryMethods instance

pull/279/head
dahall 2022-01-22 15:30:42 -07:00
parent 5a511172ea
commit 4ce428215c
1 changed files with 8 additions and 0 deletions

View File

@ -325,6 +325,10 @@ namespace Vanara.InteropServices
return h;
}
/// <summary>Gets a copy of bytes from the allocated memory block.</summary>
/// <returns>A byte array with the copied bytes.</returns>
public byte[] GetBytes() => GetBytes(0, Size);
/// <summary>Gets a copy of bytes from the allocated memory block.</summary>
/// <param name="startIndex">The start index.</param>
/// <param name="count">The number of bytes to retrieve.</param>
@ -451,6 +455,10 @@ namespace Vanara.InteropServices
/// <summary>When overridden in a derived class, gets a value indicating whether the handle value is invalid.</summary>
public override bool IsInvalid => handle == IntPtr.Zero;
/// <summary>Gets a value indicating whether this memory supports locking.</summary>
/// <value><see langword="true"/> if lockable; otherwise, <see langword="false"/>.</value>
public override bool Lockable => mm.Lockable;
/// <summary>Gets or sets the size in bytes of the allocated memory block.</summary>
/// <value>The size in bytes of the allocated memory block.</value>
public override SizeT Size