Interface IDataType
The data type that is specified for a particular value type. It provides methods to convert values to and from binary. Diffusion provides several IDataTypes implementations.
Namespace: PushTechnology.ClientInterface.Data
Assembly: Diffusion.Client.dll
Syntax
public interface IDataType
Remarks
Value types should provide a System.Object.ToString() and define reasonable System.Object.Equals(System.Object).
A data type can optionally support incremental changes to values, represented by one or more types of delta. A delta is the difference between two values. For large or composite values that change in small steps, it is more efficient to transmit an initial value followed by a delta for each change than to transmit a complete value for each change. The data type provides an implementation of IDeltaType for each type of delta it supports via DeltaType(String) and DeltaType(Type).
Since 5.8
Properties
TypeName
Returns the external type identifier.
Declaration
string TypeName { get; }
Property Value
| Type | Description |
|---|---|
| System.String | The external type identifier. |
Methods
CanReadAs(Type)
Checks whether this data type is compatible with the given resultType.
Declaration
bool CanReadAs(Type resultType)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | resultType | The type to check for compatibility. |
Returns
| Type | Description |
|---|---|
| System.Boolean | True if the data type is compatible with the given |
Remarks
This means that any valid binary representation of this data type can be read as an instance of the given
resultType.
Any value type can be read as a System.Object resultType.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | The given |
DeltaType(String)
Returns a IDeltaType by name.
Declaration
IDeltaType DeltaType(string typeName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | typeName | The delta type name as returned by Name. |
Returns
| Type | Description |
|---|---|
| IDeltaType | The delta type. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | This data type does not provide a IDeltaType with the given name. |
DeltaType(Type)
Returns a IDeltaType by type.
Declaration
IDeltaType DeltaType(Type valueDeltaType)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | valueDeltaType | The delta value type. |
Returns
| Type | Description |
|---|---|
| IDeltaType | The delta type. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | This data type does not provide a IDeltaType for the given type or it provides more than one IDeltaType but none is preferred. |
ReadAs(Type, IBytes)
Creates a value of a compatible type from binary.
Declaration
object ReadAs(Type resultType, IBytes bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | resultType | The type of the result. |
| IBytes | bytes | The binary data. |
Returns
| Type | Description |
|---|---|
| System.Object | The value object. |
Remarks
This is equivalent to calling ReadAs(type, input.ToByteArray()).
Any value type can be read as a System.Object resultType.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | The given |
| System.ArgumentException | Failed to read |
| System.IO.InvalidDataException | The given |
ReadAs(Type, Byte[])
Creates a value of a compatible type from a binary data segment.
Declaration
object ReadAs(Type resultType, byte[] input)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | resultType | The type of the result. |
| System.Byte[] | input | The binary data. The implementation may re-use the array to avoid copying. The caller must ensure the array is not modified. |
Returns
| Type | Description |
|---|---|
| System.Object | The value object. |
Remarks
This is equivalent to calling ReadAs(type, input, 0, input.Length).
Any value type can be read as a System.Object resultType.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | The given |
| System.ArgumentException | Failed to read |
| System.InvalidOperationException | The given |
ReadAs(Type, Byte[], Int32, Int32)
Creates a value of a compatible type from a binary data segment.
Declaration
object ReadAs(Type resultType, byte[] input, int offset, int length)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | resultType | The type of the result. |
| System.Byte[] | input | The binary data. The implementation may re-use the array to avoid copying. The caller must ensure the array is not modified. |
| System.Int32 | offset | The starting index of the data segment. |
| System.Int32 | length | The length of the data segment. |
Returns
| Type | Description |
|---|---|
| System.Object | The value object. |
Remarks
Any value type can be read as a System.Object resultType.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | The given |
| System.ArgumentException | Failed to read |
| System.InvalidOperationException | The given |
ReadValue(IBytes)
Parses a value from binary.
Declaration
object ReadValue(IBytes bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| IBytes | bytes | The binary data. |
Returns
| Type | Description |
|---|---|
| System.Object | The value object. |
Remarks
This is equivalent to ReadValue(bytes.ToByteArray()).
ReadValue(Byte[])
Parses a value from a binary.
Declaration
object ReadValue(byte[] input)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | input | The binary data. The implementation may re-use the array to avoid copying. The caller must ensure the array is not modified. |
Returns
| Type | Description |
|---|---|
| System.Object | The value object. |
Remarks
This is equivalent to ReadValue(input,0,input.Length).
ReadValue(Byte[], Int32, Int32)
Parses a value from a binary data segment.
Declaration
object ReadValue(byte[] input, int offset, int length)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | input | The binary data. The implementation may re-use the array to avoid copying. The caller must ensure the array is not modified. |
| System.Int32 | offset | The starting index of the data segment. |
| System.Int32 | length | The length of the data segment. |
Returns
| Type | Description |
|---|---|
| System.Object | The value object. |
ToBytes(Object)
Returns the serialized form of the given value as IBytes.
Declaration
IBytes ToBytes(object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | value | The value to serialize. |
Returns
| Type | Description |
|---|---|
| IBytes | The IBytes representing the serialized form of the given |
Remarks
Since 6.0
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Failed to read |
Validate(Object)
Checks whether a value is valid.
Declaration
void Validate(object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | value | The value object to check for validity. |
Remarks
A DataType implementation is not required to check the binary data supplied to ReadValue(Byte[], Int32, Int32). This method can be used the check the value at a later time.
Exceptions
| Type | Condition |
|---|---|
| System.IO.InvalidDataException | The given value is invalid. |
WriteValue(Object, Stream)
Serializes a value to binary.
Declaration
void WriteValue(object value, Stream outputStream)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | value | The value object. |
| System.IO.Stream | outputStream | The output stream. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | The given |