using System;
using System.IO;
namespace Org.Mentalis.Security.Ssl.Shared {
///
/// Creates a stream whose backing store is memory.
///
/// This class is created by Kevin Knoop.
internal class XBuffer : MemoryStream {
///
/// Initializes a new instance of the XBuffer class with an expandable capacity initialized to zero.
///
public XBuffer() : base() {
//
}
///
/// Removes a number of leading bytes from the buffer.
///
/// The number of bytes to remove.
/// is invalid.
public void RemoveXBytes(int aByteCount) {
if (aByteCount > Length) {
throw new ArgumentException("Not enough data in buffer");
}
if (aByteCount == Length) {
SetLength(0);
} else {
byte[] buff = GetBuffer();
Array.Copy(buff, aByteCount, buff, 0, (int)Length-aByteCount);
SetLength(Length-aByteCount);
}
}
}
}