Diffusion .NET Classic API - Core and Common  5.9.4
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
PushTechnology.DiffusionCore.Connection.Common.IO.Serialisation.IByteBufferSerialiser< in T > Interface Template Reference

Serialise an object to a byte buffer. More...

Inherited by PushTechnology.DiffusionCore.Connection.Common.IO.Serialisation.AbstractByteBufferSerialiser< T >.

Public Member Functions

bool Write (ByteBuffer destination, T value)
 Write an instance to a byte buffer. More...
 

Detailed Description

Serialise an object to a byte buffer.

Template Parameters
T

Member Function Documentation

bool PushTechnology.DiffusionCore.Connection.Common.IO.Serialisation.IByteBufferSerialiser< in T >.Write ( ByteBuffer  destination,
value 
)

Write an instance to a byte buffer.

On entry, the position of destination should point to the write position, and the limit should be adequate to accept some data.

There are three outcomes to consider:

  1. On success, the implementation should return true and leave the position after the written bytes. The implementation should not alter the limit. Implementations may arbitrarily set the mark.
  2. If the implementation cannot write the data because of value , it should throw an ArgumentException.
  3. If there is sufficient space to write the data, the implementation should reset the position to the start of the buffer and return false. The implementation should not throw BufferUnderflowException. This allows the caller to provide extra space and try again, and allows optimised implementations to avoid the cost of exceptions.
Parameters
destinationThe destination (target) buffer.
valueThe instance to write.
Returns
true on success, or false or there is insufficient space; see above for the full contract.