VariantHelpers
Overview
The VariantHelpers utility class provides methods to read variant data types from the stream or write data to it. This class relies on BinSerializer to perform actual write or read operations.
Location
- Reference: RemObjects.SDK.dll
- Namespace: RemObjects.SDK.Helpers
Class Methods
BinaryFromVariant
Returns a new Binary stream that contains provided value in its serialized form.
class method BinaryFromVariant(value: Object): Binary
static Binary BinaryFromVariant(Object value)
Shared Function BinaryFromVariant(value As Object) As Binary
Parameters:
- value: Value that vill be serialized as Variant
GetStreamingFormat
Returns the streaming format best matching the provided data typename.
This method is used by serializers to determine the data serializartion format for cusom arrays (ie arrays implementing the IArrayType interface).
class method GetStreamingFormat(dataTypeName: String): StreamingFormat
static StreamingFormat GetStreamingFormat(String dataTypeName)
Shared Function GetStreamingFormat(dataTypeName As String) As StreamingFormat
Parameters:
- dataTypeName: Data type name, f.e. WideString or Currency
GetTypeForVariantCode
Returns .NET framework type matching the provided VariantCode value. F.e. for the VariantCode value this method will return the Double .NET type. See the VariantCode enum description for the full list of possible values and their .NET type equivalents.
Raises VariantException exception in case when provided variant code doesn't match any .NET type.
class method GetTypeForVariantCode(typeCode: VariantCode): Type
static Type GetTypeForVariantCode(VariantCode typeCode)
Shared Function GetTypeForVariantCode(typeCode As VariantCode) As Type
Parameters:
- typeCode: Variant type code
GetVariantCodeForType
Returns VariantCode value matching the provided .NET type. F.e. for the Double .NET type this method will return VariantCode. See the VariantCode enum description for the full list of possible values and their .NET type equivalents.
Raises VariantException exception in case when provided .NET type doesn't have matching variant code.
class method GetVariantCodeForType(type: Type): VariantCode
static VariantCode GetVariantCodeForType(Type type)
Shared Function GetVariantCodeForType(type As Type) As VariantCode
Parameters:
- type: .NET type
IsValueSupportedAsVariant (Object): Boolean
Checks if the provided object can be represented as variant data type. In case when provided value is an array checks that all elements of ths array can be represented as variant data type.
class method IsValueSupportedAsVariant(value: Object): Boolean
static Boolean IsValueSupportedAsVariant(Object value)
Shared Function IsValueSupportedAsVariant(value As Object) As Boolean
Parameters:
- value: Value to check
IsValueSupportedAsVariant (Object, Boolean): Boolean
Checks if the provided object can be represented as variant data type. In case when provided value is an array checks that all elements of ths array can be represented as variant data type.
The following types and values are considered as allowed:
- null value
- Array of bytes
- Descendants of the ComplexType type (depends on the value of the allowComplexType parameter)
- Boolean
- Byte
- DateTime
- Decimal
- Double
- Guid
- Int16
- Int32
- Int64
- SByte
- String
- UInt16
- UInt32
class method IsValueSupportedAsVariant(value: Object; allowComplexType: Boolean): Boolean
static Boolean IsValueSupportedAsVariant(Object value, Boolean allowComplexType)
Shared Function IsValueSupportedAsVariant(value As Object, allowComplexType As Boolean) As Boolean
Parameters:
- value: Value to check
- allowComplexType: Flag indicating whether descendants of the ComplexType type should be considered as acceptable
ReadVariantFromStream (BinSerializer): Object
Reads and returns the next object in the binary stream assotiated with the provided serializer instance.
class method ReadVariantFromStream(serializer: BinSerializer): Object
static Object ReadVariantFromStream(BinSerializer serializer)
Shared Function ReadVariantFromStream(serializer As BinSerializer) As Object
Parameters:
- serializer: Serializer instance assotiated with the data stream containing the serialized Variant values
ReadVariantFromStream (Stream): Object
Reads and returns the next object in the provided data stream. A BinSerializer class instance is created automatically to perform the data deserialization operation.
class method ReadVariantFromStream(stream: Stream): Object
static Object ReadVariantFromStream(Stream stream)
Shared Function ReadVariantFromStream(stream As Stream) As Object
Parameters:
- stream: Data stream containing serialized Variant values
VariantFromBinary
Reads and returns the next object in the provided Binary instance.
class method VariantFromBinary(value: Binary): Object
static Object VariantFromBinary(Binary value)
Shared Function VariantFromBinary(value As Binary) As Object
Parameters:
- value: Binary instance containing serialized Variant values
WriteVariantToStream (Object, BinSerializer)
Writes the data type code and value of the passed object into the stream assotiated with the provided serializer instance.
class method WriteVariantToStream(value: Object; serializer: BinSerializer)
static void WriteVariantToStream(Object value, BinSerializer serializer)
Shared Sub WriteVariantToStream(value As Object, serializer As BinSerializer)
Parameters:
- value: Value that vill be serialized as Variant
- serializer: Serializer instance assotiated with the data stream containing the serialized Variant values
WriteVariantToStream (Object, Stream)
Writes the data type code and value of the passed object into the stream. A BinSerializer class instance is created automatically to perform the data serialization operation.
class method WriteVariantToStream(value: Object; stream: Stream)
static void WriteVariantToStream(Object value, Stream stream)
Shared Sub WriteVariantToStream(value As Object, stream As Stream)
Parameters:
- value: Value that vill be serialized as Variant
- stream: Data stream containing serialized Variant values