public virtual void TestWrite()
		{
			MarshallingBuffer buffer = new MarshallingBuffer();
			buffer.WriteInt(Data1);
			buffer.WriteByte(Data2);
			ByteArrayBuffer content = InspectContent(buffer);
			Assert.AreEqual(Data1, content.ReadInt());
			Assert.AreEqual(Data2, content.ReadByte());
		}
		public virtual void TestTransferLastWrite()
		{
			MarshallingBuffer buffer = new MarshallingBuffer();
			buffer.WriteInt(Data1);
			int lastOffset = Offset(buffer);
			buffer.WriteByte(Data2);
			MarshallingBuffer other = new MarshallingBuffer();
			buffer.TransferLastWriteTo(other, true);
			Assert.AreEqual(lastOffset, Offset(buffer));
			ByteArrayBuffer content = InspectContent(other);
			Assert.AreEqual(Data2, content.ReadByte());
		}
Example #3
0
        private void WriteLink(MarshallingBuffer child, int position, int length)
        {
            int offset = Offset();

            _delegate.Seek(child.AddressInParent());
            _delegate.WriteInt(position);
            if (child.StoreLengthInLink())
            {
                _delegate.WriteInt(length);
            }
            _delegate.Seek(offset);
        }
Example #4
0
        public virtual MarshallingBuffer AddChild(bool reserveLinkSpace, bool storeLengthInLink
                                                  )
        {
            MarshallingBuffer child = new MarshallingBuffer();

            child.AddressInParent(Offset(), storeLengthInLink);
            _children = new List4(_children, child);
            if (reserveLinkSpace)
            {
                ReserveChildLinkSpace(storeLengthInLink);
            }
            return(child);
        }
		public MarshallingContext(Db4objects.Db4o.Internal.Transaction trans, ObjectReference
			 @ref, IUpdateDepth updateDepth, bool isNew)
		{
			// YapClass ID
			// Marshaller Version
			// number of fields
			_transaction = trans;
			_reference = @ref;
			_nullBitMap = new BitMap4(AspectCount());
			_updateDepth = ClassMetadata().AdjustUpdateDepth(trans, updateDepth);
			_isNew = isNew;
			_writeBuffer = new MarshallingBuffer();
			_currentBuffer = _writeBuffer;
		}
Example #6
0
        public virtual void TransferLastWriteTo(MarshallingBuffer other, bool storeLengthInLink
                                                )
        {
            other.AddressInParent(_lastOffSet, storeLengthInLink);
            int length = _delegate.Offset() - _lastOffSet;

            other.PrepareWrite(length);
            int otherOffset = other._delegate.Offset();

            System.Array.Copy(_delegate._buffer, _lastOffSet, other._delegate._buffer, otherOffset
                              , length);
            _delegate.Seek(_lastOffSet);
            other._delegate.Seek(otherOffset + length);
            other._lastOffSet = otherOffset;
        }
Example #7
0
        private static void MergeChildren(MarshallingContext context, int masterAddress,
                                          MarshallingBuffer writeBuffer, MarshallingBuffer parentBuffer, int linkOffset)
        {
            if (parentBuffer._children == null)
            {
                return;
            }
            IEnumerator i = new Iterator4Impl(parentBuffer._children);

            while (i.MoveNext())
            {
                Merge(context, masterAddress, writeBuffer, parentBuffer, (MarshallingBuffer)i.Current
                      , linkOffset);
            }
        }
		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());
		}
Example #9
0
        private static void Merge(MarshallingContext context, int masterAddress, MarshallingBuffer
                                  writeBuffer, MarshallingBuffer parentBuffer, MarshallingBuffer childBuffer, int
                                  linkOffset)
        {
            int childPosition = writeBuffer.Offset();

            writeBuffer.Reserve(childBuffer.BlockedLength());
            MergeChildren(context, masterAddress, writeBuffer, childBuffer, linkOffset);
            int savedWriteBufferOffset = writeBuffer.Offset();

            writeBuffer.Seek(childPosition);
            childBuffer.TransferContentTo(writeBuffer._delegate);
            writeBuffer.Seek(savedWriteBufferOffset);
            parentBuffer.WriteLink(childBuffer, childPosition + linkOffset, childBuffer.UnblockedLength
                                       ());
            childBuffer.WriteIndex(context, masterAddress, childPosition + linkOffset);
        }
 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());
 }
Example #11
0
 public virtual MarshallingBuffer CheckBlockAlignment(MarshallingContext context,
                                                      MarshallingBuffer precedingBuffer, IntByRef precedingLength)
 {
     _lastOffSet = Offset();
     if (DoBlockAlign())
     {
         precedingBuffer.BlockAlign(context, precedingLength.value);
     }
     if (precedingBuffer != null)
     {
         precedingLength.value += precedingBuffer.Length();
     }
     precedingBuffer = this;
     if (_children != null)
     {
         IEnumerator i = new Iterator4Impl(_children);
         while (i.MoveNext())
         {
             precedingBuffer = ((MarshallingBuffer)i.Current).CheckBlockAlignment(context, precedingBuffer
                                                                                  , precedingLength);
         }
     }
     return(precedingBuffer);
 }
Example #12
0
 public _IReservedBuffer_178(MarshallingBuffer _enclosing)
 {
     this._enclosing     = _enclosing;
     this.reservedOffset = this._enclosing._delegate.Offset();
 }
		private ByteArrayBuffer InspectContent(MarshallingBuffer buffer)
		{
			ByteArrayBuffer bufferDelegate = buffer.TestDelegate();
			bufferDelegate.Seek(0);
			return bufferDelegate;
		}
		private int Offset(MarshallingBuffer buffer)
		{
			return buffer.TestDelegate().Offset();
		}
		public virtual int RequiredLength(MarshallingBuffer buffer, bool align)
		{
			if (!align)
			{
				return buffer.Length();
			}
			return Container().BlockConverter().BlockAlignedBytes(buffer.Length());
		}
		public virtual void TestLinkOffset()
		{
			int linkOffset = 7;
			MarshallingBuffer buffer = new MarshallingBuffer();
			buffer.WriteInt(Data1);
			buffer.WriteByte(Data2);
			MarshallingBuffer child = buffer.AddChild();
			child.WriteInt(Data3);
			child.WriteInt(Data4);
			MarshallingBuffer grandChild = child.AddChild();
			grandChild.WriteInt(Data5);
			buffer.MergeChildren(null, 0, linkOffset);
			ByteArrayBuffer content = InspectContent(buffer);
			ByteArrayBuffer 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());
			int 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());
		}
Example #17
0
		private void WriteLink(MarshallingBuffer child, int position, int length)
		{
			int offset = Offset();
			_delegate.Seek(child.AddressInParent());
			_delegate.WriteInt(position);
			if (child.StoreLengthInLink())
			{
				_delegate.WriteInt(length);
			}
			_delegate.Seek(offset);
		}
Example #18
0
		public virtual MarshallingBuffer CheckBlockAlignment(MarshallingContext context, 
			MarshallingBuffer precedingBuffer, IntByRef precedingLength)
		{
			_lastOffSet = Offset();
			if (DoBlockAlign())
			{
				precedingBuffer.BlockAlign(context, precedingLength.value);
			}
			if (precedingBuffer != null)
			{
				precedingLength.value += precedingBuffer.Length();
			}
			precedingBuffer = this;
			if (_children != null)
			{
				IEnumerator i = new Iterator4Impl(_children);
				while (i.MoveNext())
				{
					precedingBuffer = ((MarshallingBuffer)i.Current).CheckBlockAlignment(context, precedingBuffer
						, precedingLength);
				}
			}
			return precedingBuffer;
		}
Example #19
0
		private static void Merge(MarshallingContext context, int masterAddress, MarshallingBuffer
			 writeBuffer, MarshallingBuffer parentBuffer, MarshallingBuffer childBuffer, int
			 linkOffset)
		{
			int childPosition = writeBuffer.Offset();
			writeBuffer.Reserve(childBuffer.BlockedLength());
			MergeChildren(context, masterAddress, writeBuffer, childBuffer, linkOffset);
			int savedWriteBufferOffset = writeBuffer.Offset();
			writeBuffer.Seek(childPosition);
			childBuffer.TransferContentTo(writeBuffer._delegate);
			writeBuffer.Seek(savedWriteBufferOffset);
			parentBuffer.WriteLink(childBuffer, childPosition + linkOffset, childBuffer.UnblockedLength
				());
			childBuffer.WriteIndex(context, masterAddress, childPosition + linkOffset);
		}
Example #20
0
			public _IReservedBuffer_178(MarshallingBuffer _enclosing)
			{
				this._enclosing = _enclosing;
				this.reservedOffset = this._enclosing._delegate.Offset();
			}
Example #21
0
		private static void MergeChildren(MarshallingContext context, int masterAddress, 
			MarshallingBuffer writeBuffer, MarshallingBuffer parentBuffer, int linkOffset)
		{
			if (parentBuffer._children == null)
			{
				return;
			}
			IEnumerator i = new Iterator4Impl(parentBuffer._children);
			while (i.MoveNext())
			{
				Merge(context, masterAddress, writeBuffer, parentBuffer, (MarshallingBuffer)i.Current
					, linkOffset);
			}
		}
Example #22
0
		public virtual MarshallingBuffer AddChild(bool reserveLinkSpace, bool storeLengthInLink
			)
		{
			MarshallingBuffer child = new MarshallingBuffer();
			child.AddressInParent(Offset(), storeLengthInLink);
			_children = new List4(_children, child);
			if (reserveLinkSpace)
			{
				ReserveChildLinkSpace(storeLengthInLink);
			}
			return child;
		}
		public virtual void CreateChildBuffer(bool storeLengthInLink)
		{
			MarshallingBuffer childBuffer = _currentBuffer.AddChild(false, storeLengthInLink);
			_currentBuffer.ReserveChildLinkSpace(storeLengthInLink);
			_currentBuffer = childBuffer;
		}
		public virtual void BeginSlot()
		{
			_currentBuffer = _writeBuffer;
		}
		public virtual void RestoreState(MarshallingContextState state)
		{
			_currentBuffer = state._buffer;
		}
Example #26
0
		public virtual void TransferLastWriteTo(MarshallingBuffer other, bool storeLengthInLink
			)
		{
			other.AddressInParent(_lastOffSet, storeLengthInLink);
			int length = _delegate.Offset() - _lastOffSet;
			other.PrepareWrite(length);
			int otherOffset = other._delegate.Offset();
			System.Array.Copy(_delegate._buffer, _lastOffSet, other._delegate._buffer, otherOffset
				, length);
			_delegate.Seek(_lastOffSet);
			other._delegate.Seek(otherOffset + length);
			other._lastOffSet = otherOffset;
		}
Example #27
0
		public MarshallingContextState(MarshallingBuffer buffer)
		{
			_buffer = buffer;
		}