RTI Connext C# API Version 7.2.0
Rti.Types.Dynamic.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...
 
DynamicType GetMemberType (string memberName)
 Returns the type of a member More...
 
DynamicType GetMemberType (int memberId)
 Returns the type of a member 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]

Rti.Types.Dynamic.DynamicData.DynamicData ( DynamicType  type)

Create a new DynamicData object for a given type

Parameters
typeThe type definition for this data sample

◆ DynamicData() [2/2]

Rti.Types.Dynamic.DynamicData.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

◆ Clone()

DynamicData Rti.Types.Dynamic.DynamicData.Clone ( )
inline

Creates a deep copy of this object

◆ CopyFrom()

void Rti.Types.Dynamic.DynamicData.CopyFrom ( DynamicData  source)

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

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

T Rti.Types.Dynamic.DynamicData.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[].

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

T Rti.Types.Dynamic.DynamicData.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[].

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

DynamicData Rti.Types.Dynamic.DynamicData.SetValue< T > ( string  memberName,
value 
)
inline

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.

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

DynamicData Rti.Types.Dynamic.DynamicData.SetValue< T > ( int  memberId,
value 
)
inline

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[].

◆ SetAnyValue() [1/2]

DynamicData Rti.Types.Dynamic.DynamicData.SetAnyValue ( string  memberName,
object  value 
)
inline

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");

◆ SetAnyValue() [2/2]

DynamicData Rti.Types.Dynamic.DynamicData.SetAnyValue ( int  memberId,
object  value 
)
inline

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

◆ GetAnyValue() [1/2]

object Rti.Types.Dynamic.DynamicData.GetAnyValue ( string  memberName)
inline

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.

◆ GetAnyValue() [2/2]

object Rti.Types.Dynamic.DynamicData.GetAnyValue ( int  memberId)
inline

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

◆ GetDiscriminatorValue()

int Rti.Types.Dynamic.DynamicData.GetDiscriminatorValue ( )
inline

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

◆ LoanValue() [1/2]

LoanedDynamicData Rti.Types.Dynamic.DynamicData.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

◆ LoanValue() [2/2]

LoanedDynamicData Rti.Types.Dynamic.DynamicData.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

◆ ClearAllMembers()

void Rti.Types.Dynamic.DynamicData.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 Rti.Types.Dynamic.DynamicData.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

◆ ClearMember() [2/2]

void Rti.Types.Dynamic.DynamicData.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

◆ ClearOptionalMember() [1/2]

void Rti.Types.Dynamic.DynamicData.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

◆ ClearOptionalMember() [2/2]

void Rti.Types.Dynamic.DynamicData.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

◆ MemberExists() [1/2]

bool Rti.Types.Dynamic.DynamicData.MemberExists ( string  memberName)

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 Rti.Types.Dynamic.DynamicData.MemberExists ( int  memberId)

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 Rti.Types.Dynamic.DynamicData.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

◆ MemberExistsInType() [2/2]

bool Rti.Types.Dynamic.DynamicData.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

◆ IsMemberKey() [1/2]

bool Rti.Types.Dynamic.DynamicData.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

◆ IsMemberKey() [2/2]

bool Rti.Types.Dynamic.DynamicData.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

◆ GetMemberType() [1/2]

DynamicType Rti.Types.Dynamic.DynamicData.GetMemberType ( string  memberName)

Returns the type of a member

Parameters
memberNameThe member name
Returns
The type of the member

◆ GetMemberType() [2/2]

DynamicType Rti.Types.Dynamic.DynamicData.GetMemberType ( int  memberId)

Returns the type of a member

Parameters
memberIdThe member ID
Returns
The type of the member

◆ GetMemberInfo() [1/2]

MemberInfo Rti.Types.Dynamic.DynamicData.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

◆ GetMemberInfo() [2/2]

MemberInfo Rti.Types.Dynamic.DynamicData.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

◆ GetMemberInfoByIndex()

MemberInfo Rti.Types.Dynamic.DynamicData.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

◆ Dispose()

void Rti.Types.Dynamic.DynamicData.Dispose ( )
inline

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

◆ ToCdrBuffer() [1/2]

byte[] Rti.Types.Dynamic.DynamicData.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 Rti.Types.Dynamic.DynamicData.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

◆ FromCdrBuffer()

void Rti.Types.Dynamic.DynamicData.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

◆ GetHashCode()

override int Rti.Types.Dynamic.DynamicData.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

◆ ToString() [1/2]

string Rti.Types.Dynamic.DynamicData.ToString ( PrintFormatProperty  format)

Get a string representation of a DynamicData object.

Parameters
formatAllows changing the print format

◆ ToString() [2/2]

override string Rti.Types.Dynamic.DynamicData.ToString ( )

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

◆ Equals() [1/2]

override bool Rti.Types.Dynamic.DynamicData.Equals ( object  other)

Indicate whether two data samples are equal

◆ Equals() [2/2]

bool Rti.Types.Dynamic.DynamicData.Equals ( DynamicData  other)
inline

Indicate whether two data samples are equal

Property Documentation

◆ Disposed

bool Rti.Types.Dynamic.DynamicData.Disposed
get

Indicates whether this object has been disposed

◆ Type

DynamicType Rti.Types.Dynamic.DynamicData.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

TypeKind Rti.Types.Dynamic.DynamicData.TypeKind
get

Get the kind of this object's data type.

The full documentation is available in the C API: DDS_DynamicData_get_type_kind

◆ MemberCount

uint Rti.Types.Dynamic.DynamicData.MemberCount
get

The number of data members in this DynamicData sample.

The full documentation is available in the C API: DDS_DynamicDataInfo_member_count

◆ Info

DynamicDataInfo Rti.Types.Dynamic.DynamicData.Info
get

Gets information about this DynamicData sample.

The full documentation is available in the C API: DDS_DynamicData_get_info