RTI Connext C# API  7.1.0
ISerializer< T > Interface Template Reference

Allows serializing and deserializing IDL types as byte buffers More...

Inherits IDisposable.

Public Member Functions

byte[] Serialize (T sample)
 Serializes a data sample into a byte array More...
 
unsafe uint Serialize (T sample, byte *buffer, int length)
 Serializes a data sample into a byte array More...
 
Deserialize (byte[] buffer)
 Deserializes a data sample from a byte array More...
 
unsafe T Deserialize (byte *buffer, int length)
 Deserializes a data sample from a byte buffer More...
 
uint GetSerializedSampleMaxSize ()
 Calculates the maximum number of bytes that any data sample of type T may take in serialized form. More...
 
uint GetSerializedSampleMinSize ()
 Calculates the minimum number of bytes that any data sample of type T may take in serialized form. More...
 
uint GetSerializedSampleSize (T sample)
 Calculates the exact number of bytes that a given data sample takes in serialized form. More...
 
DynamicData ToDynamicData (T sample)
 Converts a T sample into a DynamicData sample. More...
 
FromDynamicData (DynamicData sample)
 Converts a DynamicData sample into a T sample. More...
 

Detailed Description

Allows serializing and deserializing IDL types as byte buffers

Template Parameters
TA type generated from IDL

To create an ISerializer, use TypeSupport<T>.CreateSerializer.

Warning
The ISerializer methods are not thread-safe. To use them in multiple threads, either protect them or create a different ISerializer per thread

This type is IDisposable, but it automatically calls Dispose() in its destructor.

This interface has extension methods, see SerializerExtensions.

See also
IDL examples

Member Function Documentation

◆ Deserialize() [1/2]

unsafe T Deserialize ( byte *  buffer,
int  length 
)

Deserializes a data sample from a byte buffer

Parameters
bufferA byte buffer containing the serialized data
lengthThe length of the byte buffer
Returns
A new data sample created by deserializing the buffer

◆ Deserialize() [2/2]

T Deserialize ( byte[]  buffer)

Deserializes a data sample from a byte array

Parameters
bufferA byte array containing the serialized data
Returns
A new data sample created by deserializing the buffer

◆ FromDynamicData()

T FromDynamicData ( DynamicData  sample)

Converts a DynamicData sample into a T sample.

Parameters
sampleThe sample to convert
Returns
A copy of sample as an instance of type T

This method requires that sample.Type and TSupport.Instance.DynamicType be equal.

◆ GetSerializedSampleMaxSize()

uint GetSerializedSampleMaxSize ( )

Calculates the maximum number of bytes that any data sample of type T may take in serialized form.

◆ GetSerializedSampleMinSize()

uint GetSerializedSampleMinSize ( )

Calculates the minimum number of bytes that any data sample of type T may take in serialized form.

◆ GetSerializedSampleSize()

uint GetSerializedSampleSize ( sample)

Calculates the exact number of bytes that a given data sample takes in serialized form.

Parameters
sampleThe data sample
Returns
The number of bytes that the sample needs to be serialized

◆ Serialize() [1/2]

byte [] Serialize ( sample)

Serializes a data sample into a byte array

Parameters
sampleA data sample
Returns
A new byte array containing the serialized data

◆ Serialize() [2/2]

unsafe uint Serialize ( sample,
byte *  buffer,
int  length 
)

Serializes a data sample into a byte array

Parameters
sampleA data sample
bufferA byte buffer with enough space to contain the serialized data
lengthThe available length of the byte buffer. This operation throws DdsException if the data doesn't fit. You can obtain the exact size required for this sample with GetSerializedSampleSize or a size that is guaranteed to suffice for any sample of this type with GetSerializedSampleMaxSize.
Returns
The actual number of bytes that were serialized

◆ ToDynamicData()

DynamicData ToDynamicData ( sample)

Converts a T sample into a DynamicData sample.

Parameters
sampleThe sample to convert
Returns
A copy of sample as a DynamicData object