/// <summary> /// Writes count bytes from the current position into data starting at offset. /// </summary> /// <param name="data">The byte array where data will be read from.</param> /// <param name="offset">The position in the byte array where those data will be read from.</param> /// <param name="count">The amount of bytes which will be read.</param> /// <remarks>BEWARE: This method is also NOT DOING input checks of the given parameters.</remarks> public unsafe void WriteBytes(byte[] data, int offset, int count) { if (data == null) { throw new ArgumentNullException("data", "data can't be null."); } if (offset < 0) { throw new ArgumentOutOfRangeException("offset", "offset can't be negative."); } if (count < 0) { throw new ArgumentOutOfRangeException("count", "count can't be negative."); } if (offset + count > data.Length) { throw new ArgumentOutOfRangeException("count", "offset + count bigger than data.Length."); } if (size < count) { Next = new ManagedBinaryMemoryWriterSegment(writer, count > 1024 ? count : 1024); Next.WriteBytes(data, offset, count); return; } fixed(byte *bData = this.data) fixed(byte *pData = data) Buffer.MemoryCopy(pData + offset, bData + position, count, count); position += count; size -= count; }
/// <summary> /// Writes count bytes from the current position into data starting at offset. /// </summary> /// <param name="data">The byte array where data will be read from.</param> /// <param name="offset">The position in the byte array where those data will be read from.</param> /// <param name="count">The amount of bytes which will be read.</param> /// <remarks>BEWARE: This method is also NOT DOING input checks of the given parameters.</remarks> public void WriteBytes(byte[] data, int offset, int count) { currentSegment.WriteBytes(data, offset, count); }