RTI Connext C# API  6.1.2
DynamicData Class Reference

A data sample of any complex data type, which can be inspected and manipulated reflectively. More...

Inherits IDisposable, and IEquatable< DynamicData >.

Public Member Functions

 DynamicData (DynamicType type)
 Create a new DynamicData object for a given type More...
 
 DynamicData (DynamicType type, DynamicDataProperty property)
 Create a new DynamicData object for a given type and custom configuration More...
 
DynamicData Clone ()
 Creates a deep copy of this object More...
 
void CopyFrom (DynamicData source)
 Copies the sample into this one, overwritting it. Both samples must have the same type. More...
 
GetValue< T > (string memberName)
 Gets value of type T using the name of the member. More...
 
GetValue< T > (int memberId)
 Gets value of type T using the id of the member. More...
 
DynamicData SetValue< T > (string memberName, T value)
 Sets value of type T using the name of the member. More...
 
DynamicData SetValue< T > (int memberId, T value)
 Sets value of type T using the id of the member. More...
 
DynamicData SetAnyValue (string memberName, object value)
 Sets a member value from any object More...
 
DynamicData SetAnyValue (int memberId, object value)
 Sets a member value from an object More...
 
object GetAnyValue (string memberName)
 Gets a member value without specifying its expected type at compilation time More...
 
object GetAnyValue (int memberId)
 Gets a member value without specifying its expected type at compilation time More...
 
int GetDiscriminatorValue ()
 Obtains the value of the union discriminator (only for unions) More...
 
LoanedDynamicData LoanValue (string memberName)
 Returns a loaned object to provide access to a complex field of this DynamicData object. More...
 
LoanedDynamicData LoanValue (int memberId)
 Returns a loaned object to provide access to a complex field of this DynamicData object. More...
 
void ClearAllMembers ()
 Clear the contents of all data members of this object. More...
 
void ClearMember (string memberName)
 Clear the contents of a single data member of this object. More...
 
void ClearMember (int memberId)
 Clear the contents of a single data member of this object. More...
 
void ClearOptionalMember (string memberName)
 Clear the contents of a single optional data member of this object. More...
 
void ClearOptionalMember (int memberId)
 Clear the contents of a single optional data member of this object. More...
 
bool MemberExists (string memberName)
 Indicates whether a member exists in this sample More...
 
bool MemberExists (int memberId)
 Indicates whether a member exists in this sample More...
 
bool MemberExistsInType (string memberName)
 Indicates whether a member is defined in this data sample's type. More...
 
bool MemberExistsInType (int memberId)
 Indicates whether a member is defined in this data sample's type. More...
 
bool IsMemberKey (string memberName)
 Indicates whether a given member forms part of the key of this sample's data type. More...
 
bool IsMemberKey (int memberId)
 Indicates whether a given member forms part of the key of this sample's data type. More...
 
MemberInfo GetMemberInfo (string memberName)
 Gets information about a member of this DynamicData sample. More...
 
MemberInfo GetMemberInfo (int memberId)
 Gets information about a member of this DynamicData sample. More...
 
MemberInfo GetMemberInfoByIndex (uint index)
 Gets information about a member (identified by its position) of this DynamicData sample. More...
 
void Dispose ()
 Releases the native resources (a finalizer is provided as well) More...
 
byte[] ToCdrBuffer ()
 Serializes a DynamicData as a CDR buffer of octets into a new array. More...
 
int ToCdrBuffer (byte[] buffer)
 Serializes a DynamicData as a CDR buffer of octets into an existing array More...
 
void FromCdrBuffer (byte[] buffer)
 Populates this DynamicData object from the serialized CDR data in a buffer More...
 
override int GetHashCode ()
 Returns a simple hash code. More...
 
string ToString (PrintFormatProperty format)
 Get a string representation of a DynamicData object. More...
 
override string ToString ()
 Get a string representation of a DynamicData object with the default format More...
 
override bool Equals (object other)
 Indicate whether two data samples are equal More...
 
bool Equals (DynamicData other)
 Indicate whether two data samples are equal More...
 

Properties

bool Disposed [get]
 Indicates whether this object has been disposed More...
 
DynamicType Type [get]
 Get the data type, of which this DynamicData represents an instance. More...
 
TypeKind TypeKind [get]
 Get the kind of this object's data type. More...
 
uint MemberCount [get]
 The number of data members in this DynamicData sample. More...
 
DynamicDataInfo Info [get]
 Gets information about this DynamicData sample. More...
 

Detailed Description

A data sample of any complex data type, which can be inspected and manipulated reflectively.

Constructor & Destructor Documentation

◆ DynamicData() [1/2]

Create a new DynamicData object for a given type

Parameters
typeThe type definition for this data sample

◆ DynamicData() [2/2]

DynamicData ( DynamicType  type,
DynamicDataProperty  property 
)

Create a new DynamicData object for a given type and custom configuration

Parameters
typeThe type definition for this data sample
propertyConfigures this object's behavior

Member Function Documentation

◆ ClearAllMembers()

void ClearAllMembers ( )

Clear the contents of all data members of this object.

The full documentation is available in the C API: DDS_DynamicData_clear_all_members

◆ ClearMember() [1/2]

void ClearMember ( int  memberId)

Clear the contents of a single data member of this object.

The full documentation is available in the C API: DDS_DynamicData_clear_member

◆ ClearMember() [2/2]

void ClearMember ( string  memberName)

Clear the contents of a single data member of this object.

The full documentation is available in the C API: DDS_DynamicData_clear_member

◆ ClearOptionalMember() [1/2]

void ClearOptionalMember ( int  memberId)

Clear the contents of a single optional data member of this object.

The full documentation is available in the C API: DDS_DynamicData_clear_optional_member

◆ ClearOptionalMember() [2/2]

void ClearOptionalMember ( string  memberName)

Clear the contents of a single optional data member of this object.

The full documentation is available in the C API: DDS_DynamicData_clear_optional_member

◆ Clone()

DynamicData Clone ( )

Creates a deep copy of this object

◆ CopyFrom()

void CopyFrom ( DynamicData  source)

Copies the sample into this one, overwritting it. Both samples must have the same type.

◆ Dispose()

void Dispose ( )

Releases the native resources (a finalizer is provided as well)

◆ Equals() [1/2]

bool Equals ( DynamicData  other)

Indicate whether two data samples are equal

◆ Equals() [2/2]

override bool Equals ( object  other)

Indicate whether two data samples are equal

◆ FromCdrBuffer()

void FromCdrBuffer ( byte[]  buffer)

Populates this DynamicData object from the serialized CDR data in a buffer

Parameters
bufferContains the serialized data

The full documentation is available in the C API: DDS_DynamicData_from_cdr_buffer

◆ GetAnyValue() [1/2]

object GetAnyValue ( int  memberId)

Gets a member value without specifying its expected type at compilation time

Parameters
memberIdThe id of the member to set
Returns
The value of that member as an object

◆ GetAnyValue() [2/2]

object GetAnyValue ( string  memberName)

Gets a member value without specifying its expected type at compilation time

Parameters
memberNameThe name of the member to set
Returns
The value of that member as an object

This function allows getting the value of member without knowing its type at compilation time. If the type is known, use the specific getter, such as GetValue<int> for ints.

◆ GetDiscriminatorValue()

int GetDiscriminatorValue ( )

Obtains the value of the union discriminator (only for unions)

Returns
The union discriminator. That is, the value that identifies which of the union members is valid

◆ GetHashCode()

override int GetHashCode ( )

Returns a simple hash code.

Warning
This method currently returns 0 always. If you need an efficient hash, implement one for each specific data type

◆ GetMemberInfo() [1/2]

MemberInfo GetMemberInfo ( int  memberId)

Gets information about a member of this DynamicData sample.

The full documentation is available in the C API: DDS_DynamicData_get_member_info

◆ GetMemberInfo() [2/2]

MemberInfo GetMemberInfo ( string  memberName)

Gets information about a member of this DynamicData sample.

The full documentation is available in the C API: DDS_DynamicData_get_member_info

◆ GetMemberInfoByIndex()

MemberInfo GetMemberInfoByIndex ( uint  index)

Gets information about a member (identified by its position) of this DynamicData sample.

The full documentation is available in the C API: DDS_DynamicData_get_member_info

◆ GetValue< T >() [1/2]

T GetValue< T > ( int  memberId)

Gets value of type T using the id of the member.

Template Parameters
TThe type of the value to retrieve. Supported types are: byte, short, ushort, int, uint, float, double, LongDouble, decimal, bool, char, long, ulong,string, DynamicData, byte[], short[], ushort[], int[], uint[], float[], double[], LongDouble[], bool[], char[], long[], ulong[].

◆ GetValue< T >() [2/2]

T GetValue< T > ( string  memberName)

Gets value of type T using the name of the member.

Template Parameters
TThe type of the value to retrieve. Supported types are: byte, short, ushort, int, uint, float, double, LongDouble, decimal, bool, char, long, ulong,string, DynamicData, byte[], short[], ushort[], int[], uint[], float[], double[], LongDouble[], bool[], char[], long[], ulong[].

◆ IsMemberKey() [1/2]

bool IsMemberKey ( int  memberId)

Indicates whether a given member forms part of the key of this sample's data type.

The full documentation is available in the C API: DDS_DynamicData_is_member_key

◆ IsMemberKey() [2/2]

bool IsMemberKey ( string  memberName)

Indicates whether a given member forms part of the key of this sample's data type.

The full documentation is available in the C API: DDS_DynamicData_is_member_key

◆ LoanValue() [1/2]

LoanedDynamicData LoanValue ( int  memberId)

Returns a loaned object to provide access to a complex field of this DynamicData object.

The full documentation is available in the C API: DDS_DynamicData_bind_complex_member

◆ LoanValue() [2/2]

LoanedDynamicData LoanValue ( string  memberName)

Returns a loaned object to provide access to a complex field of this DynamicData object.

The full documentation is available in the C API: DDS_DynamicData_bind_complex_member

◆ MemberExists() [1/2]

bool MemberExists ( int  memberId)

Indicates whether a member exists in this sample

The full documentation is available in the C API: DDS_DynamicData_member_exists

◆ MemberExists() [2/2]

bool MemberExists ( string  memberName)

Indicates whether a member exists in this sample

The full documentation is available in the C API: DDS_DynamicData_member_exists

◆ MemberExistsInType() [1/2]

bool MemberExistsInType ( int  memberId)

Indicates whether a member is defined in this data sample's type.

The full documentation is available in the C API: DDS_DynamicData_member_exists_in_type

◆ MemberExistsInType() [2/2]

bool MemberExistsInType ( string  memberName)

Indicates whether a member is defined in this data sample's type.

The full documentation is available in the C API: DDS_DynamicData_member_exists_in_type

◆ SetAnyValue() [1/2]

DynamicData SetAnyValue ( int  memberId,
object  value 
)

Sets a member value from an object

Parameters
memberIdThe id of the member to set
valueThe value to set. This method will try to convert it to the type of the member

◆ SetAnyValue() [2/2]

DynamicData SetAnyValue ( string  memberName,
object  value 
)

Sets a member value from any object

Parameters
memberNameThe name of the member to set
valueThe value to set. This method will try to convert it to the type of the member

This method allows setting a member value without knowing the type of the value at compilation time. If the runtime type of value doesn't coincide with the type of the member type, this method uses System.Convert to attempt to convert it. If the conversion is not possible, any of the exceptions thrown by System.Convert may be thrown by this method as well.

This method provides great flexibility, but is less efficient than the concrete setters.

The following example shows how to set an integer from a string:

sample.SetAnyValue("my_int", "45");

◆ SetValue< T >() [1/2]

DynamicData SetValue< T > ( int  memberId,
value 
)

Sets value of type T using the id of the member.

Template Parameters
TThe type of the value to retrieve. Supported types are: byte, short, ushort, int, uint, float, double, LongDouble, decimal, bool, char, long, ulong, string, DynamicData, byte[], short[], ushort[], int[], uint[], float[], double[], LongDouble[], bool[], char[], long[], ulong[].

◆ SetValue< T >() [2/2]

DynamicData SetValue< T > ( string  memberName,
value 
)

Sets value of type T using the name of the member.

Template Parameters
TThe type of the value to retrieve. Supported types are: byte, short, ushort, int, uint, float, double, LongDouble, decimal, bool, char, long, ulong,string, DynamicData, byte[], short[], ushort[], int[], uint[], float[], double[], LongDouble[], bool[], char[], long[], ulong[].

The type of the value, T, must coincide with the declared type of the member. T is string for both regular IDL string and IDL wstring. If the member is an aggregation or a collection, T is DynamicData. SetAnyValue(string, object) can be used to perform conversion from T to the declared type of the member.

◆ ToCdrBuffer() [1/2]

byte [] ToCdrBuffer ( )

Serializes a DynamicData as a CDR buffer of octets into a new array.

Returns
A new array with the serialized data

The full documentation is available in the C API: DDS_DynamicData_to_cdr_buffer

◆ ToCdrBuffer() [2/2]

int ToCdrBuffer ( byte[]  buffer)

Serializes a DynamicData as a CDR buffer of octets into an existing array

Parameters
bufferAn existing buffer where to write the serialized data. It needs to have enough space to include the data or the operation will fail. You can use StructType.GetCdrSerializedSampleMaxSize to get the max possible size
Returns
The number of bytes that were written into the buffer

The full documentation is available in the C API: DDS_DynamicData_to_cdr_buffer

◆ ToString() [1/2]

override string ToString ( )

Get a string representation of a DynamicData object with the default format

◆ ToString() [2/2]

string ToString ( PrintFormatProperty  format)

Get a string representation of a DynamicData object.

Parameters
formatAllows changing the print format

Property Documentation

◆ Disposed

bool Disposed
get

Indicates whether this object has been disposed

◆ Info

DynamicDataInfo Info
get

Gets information about this DynamicData sample.

The full documentation is available in the C API: DDS_DynamicData_get_info

◆ MemberCount

uint MemberCount
get

The number of data members in this DynamicData sample.

The full documentation is available in the C API: DDS_DynamicDataInfo::member_count

◆ Type

DynamicType Type
get

Get the data type, of which this DynamicData represents an instance.

The full documentation is available in the C API: DDS_DynamicData_get_type

◆ TypeKind

Get the kind of this object's data type.

The full documentation is available in the C API: DDS_DynamicData_get_type_kind