public void RemoveRangeFromStart(int start, int length)
        {
            var moveLength = this.Length - length;
            var tempBuffer = new byte[moveLength];
            var moveSpan   = this.innerBuffer.AsSpan(start + length, moveLength);

            MemoryExtention.Copy(tempBuffer, moveSpan);
            MemoryExtention.Copy(this.innerBuffer.AsSpan(start, moveLength), tempBuffer);

            this.Length = moveLength;
        }
        public bool SetBufferSize(int newSize = 0)
        {
            bool isGrow = false;

            if (this.innerBuffer.Length < newSize)
            {
                var oldBuffer = this.innerBuffer;
                this.innerBuffer = new byte[this.packetSize * ((newSize / this.packetSize) + 1)];
                MemoryExtention.Copy(this.AsSpan(0, oldBuffer.Length), oldBuffer);

                isGrow = true;
            }

            this.Length = newSize;

            return(isGrow);
        }
 public void Clear()
 {
     MemoryExtention.Clear(this.innerBuffer);
 }
        public void CopyFrom(ReadOnlySpan <byte> fromBuffer, int myOffset = 0)
        {
            var spanBuffer = this.AsSpan(myOffset, Math.Min(fromBuffer.Length, this.Length - myOffset));

            MemoryExtention.Copy(spanBuffer, fromBuffer);
        }
        public void Add(ReadOnlySpan <byte> addBuffer)
        {
            this.SetBufferSize(this.Length + addBuffer.Length);

            MemoryExtention.Copy(this.AsSpan(this.Length - addBuffer.Length, addBuffer.Length), addBuffer);
        }