/// <summary> /// Appends the given memory bytes by pointing <see cref="ReadOnlySequenceSegment{T}.Next"/> to a new <see cref="BytesSegment"/>. /// </summary> /// <param name="mem">The memory bytes to append.</param> /// <returns>The new instance of <see cref="BytesSegment"/>, pointing to the segment after this one.</returns> public BytesSegment Append(ReadOnlyMemory <byte> mem) { var segment = new BytesSegment(mem) { RunningIndex = this.RunningIndex + this.Memory.Length, }; this.Next = segment; return(segment); }
/// <summary> /// Appends the given <see cref="BytesSegment"/> to another. /// </summary> /// <param name="nextSegment">A reference to the next segment.</param> public void Append(BytesSegment nextSegment) { nextSegment.RunningIndex = this.RunningIndex + this.Memory.Length; this.Next = nextSegment; }