-
Notifications
You must be signed in to change notification settings - Fork 5
SafeMemoryStream
undergroundwires edited this page Jan 4, 2020
·
6 revisions
SafeMemoryStream
is a FIFO stream where it'll clear all of the read and written data. Read more about FIFO on wiki
Your input buffer will be cleared on writing:
using(var stream = new SafeMemoryStream())
{
var buffer = new byte[] {5, 10, 15, 20, 25, 30};
sut.Write(buffer,0, buffer.Length); //input buffer will be cleared after its written
}
Your stream will be cleared on reading:
using(var stream = new SafeMemoryStream())
{
var buffer = new byte[] {5, 10, 15, 20, 25, 30};
sut.Write(buffer,0, buffer.Length);
var firstThreeBytes = new byte[3];
sut.Read(firstThreeBytes ,0, 3); // first three bytes will be cleared & length of the stream will be reduced
}