public void Add(byte[] group)
{
if (this.buffer == null)
{
this.buffer = group;
this.next = group.Length;
return;
}
if (this.align != 0)
{
if (this.align == -1)
{
this.next = DataConverter.Align(this.next, group.Length);
}
else
{
this.next = DataConverter.Align(this.next, this.align);
}
this.align = 0;
}
if (this.next + group.Length > this.buffer.Length)
{
byte[] destinationArray = new byte[Math.Max(this.next, 16) * 2 + group.Length];
Array.Copy(this.buffer, destinationArray, this.buffer.Length);
Array.Copy(group, 0, destinationArray, this.next, group.Length);
this.next += group.Length;
this.buffer = destinationArray;
}
else
{
Array.Copy(group, 0, this.buffer, this.next, group.Length);
this.next += group.Length;
}
}