public void TestWriteTo() { var backingBytes = new byte[100]; using (var buffer = new ByteArrayBuffer(backingBytes, 0, 0, false)) { buffer.WriteBytes(new[] { (byte)1, (byte)2 }); using (var memoryStream = new MemoryStream()) { buffer.WriteTo(memoryStream); Assert.AreEqual(2, memoryStream.Length); } } }
public void TestWriteBytes() { var bytes = new[] { (byte)1, (byte)2 }; var backingBytes = new byte[100]; using (var buffer = new ByteArrayBuffer(backingBytes, 10, 80, false)) { Assert.AreEqual(0, backingBytes[30]); Assert.AreEqual(0, backingBytes[31]); Assert.AreEqual(0, backingBytes[32]); buffer.WriteBytes(20, bytes, 0, bytes.Length); Assert.AreEqual(1, backingBytes[30]); Assert.AreEqual(2, backingBytes[31]); Assert.AreEqual(0, backingBytes[32]); } }
public void TestWriteBytes() { var bytes = new[] { (byte)1, (byte)2 }; var backingBytes = new byte[100]; using (var buffer = new ByteArrayBuffer(backingBytes, 0, 0, false)) { Assert.AreEqual(0, backingBytes[0]); Assert.AreEqual(0, backingBytes[1]); Assert.AreEqual(0, backingBytes[2]); buffer.WriteBytes(bytes); Assert.AreEqual(1, backingBytes[0]); Assert.AreEqual(2, backingBytes[1]); Assert.AreEqual(0, backingBytes[2]); Assert.AreEqual(2, buffer.Position); Assert.AreEqual(2, buffer.Length); } }
private void WriteIdSlotPairsTo(IList slots, ByteArrayBuffer buffer) { buffer.WriteInt(slots.Count); for (IEnumerator idSlotPairIter = slots.GetEnumerator(); idSlotPairIter.MoveNext( );) { Pair idSlotPair = ((Pair)idSlotPairIter.Current); int id = (((int)idSlotPair.first)); Slot slot = ((Slot)idSlotPair.second); if (Slot.IsNull(slot)) { buffer.WriteInt(id); buffer.WriteInt(0); continue; } ByteArrayBuffer slotBuffer = _transaction.LocalContainer().ReadBufferBySlot(slot); buffer.WriteInt(id); buffer.WriteInt(slot.Length()); buffer.WriteBytes(slotBuffer._buffer); } }
public virtual void WriteBytes(byte[] bytes) { _current.WriteBytes(bytes); }