public virtual void TestGrandChildren() { var buffer = new MarshallingBuffer(); buffer.WriteInt(Data1); buffer.WriteByte(Data2); var child = buffer.AddChild(); child.WriteInt(Data3); child.WriteInt(Data4); var grandChild = child.AddChild(); grandChild.WriteInt(Data5); buffer.MergeChildren(null, 0, 0); var content = InspectContent(buffer); Assert.AreEqual(Data1, content.ReadInt()); Assert.AreEqual(Data2, content.ReadByte()); var address = content.ReadInt(); content.Seek(address); Assert.AreEqual(Data3, content.ReadInt()); Assert.AreEqual(Data4, content.ReadInt()); address = content.ReadInt(); content.Seek(address); Assert.AreEqual(Data5, content.ReadInt()); }
public virtual void TestLinkOffset() { var linkOffset = 7; var buffer = new MarshallingBuffer(); buffer.WriteInt(Data1); buffer.WriteByte(Data2); var child = buffer.AddChild(); child.WriteInt(Data3); child.WriteInt(Data4); var grandChild = child.AddChild(); grandChild.WriteInt(Data5); buffer.MergeChildren(null, 0, linkOffset); var content = InspectContent(buffer); var extendedBuffer = new ByteArrayBuffer(content.Length() + linkOffset ); content.CopyTo(extendedBuffer, 0, linkOffset, content.Length()); extendedBuffer.Seek(linkOffset); Assert.AreEqual(Data1, extendedBuffer.ReadInt()); Assert.AreEqual(Data2, extendedBuffer.ReadByte()); var address = extendedBuffer.ReadInt(); extendedBuffer.Seek(address); Assert.AreEqual(Data3, extendedBuffer.ReadInt()); Assert.AreEqual(Data4, extendedBuffer.ReadInt()); address = extendedBuffer.ReadInt(); extendedBuffer.Seek(address); Assert.AreEqual(Data5, extendedBuffer.ReadInt()); }
public virtual ByteArrayBuffer ToWriteBuffer(Pointer4 pointer) { ByteArrayBuffer buffer = new ByteArrayBuffer(pointer.Length()); _writeBuffer.MergeChildren(this, pointer.Address(), WriteBufferOffset()); WriteObjectClassID(buffer, ClassMetadata().GetID()); buffer.WriteByte(HandlerRegistry.HandlerVersion); buffer.WriteInt(AspectCount()); buffer.WriteBitMap(_nullBitMap); _writeBuffer.TransferContentTo(buffer); return(buffer); }
public virtual void TestChildren() { MarshallingBuffer buffer = new MarshallingBuffer(); buffer.WriteInt(Data1); buffer.WriteByte(Data2); MarshallingBuffer child = buffer.AddChild(); child.WriteInt(Data3); child.WriteInt(Data4); buffer.MergeChildren(null, 0, 0); ByteArrayBuffer content = InspectContent(buffer); Assert.AreEqual(Data1, content.ReadInt()); Assert.AreEqual(Data2, content.ReadByte()); int address = content.ReadInt(); content.Seek(address); Assert.AreEqual(Data3, content.ReadInt()); Assert.AreEqual(Data4, content.ReadInt()); }