Diffusion .NET Client Library
6.1.5
|
The optional extension provided by IDataType implementations that support incremental changes to values. More...
Public Member Functions | |
void | WriteDelta (object delta, Stream outputStream) |
Serializes a delta to binary. More... | |
IBytes | ToBytes (object delta) |
Returns the serialized form of the given delta as IBytes. More... | |
object | ReadDelta (byte[] input, int offset, int length) |
Creates a delta from binary segment. More... | |
object | ReadDelta (byte[] input) |
Creates a delta from binary segment. More... | |
object | ReadDelta (IBytes input) |
Creates a delta from IBytes. More... | |
object | Diff (object oldValue, object newValue) |
Creates a delta from two values. More... | |
object | Apply (object oldValue, object delta) |
Applies a delta to a value. More... | |
bool | IsValueCheaper (object value, object delta) |
Calculates if value is cheaper than delta . The result is typically determined by the length of the serialized form but can also consider the complexity of the delta. More... | |
Properties | |
string | Name [get] |
Returns the external identifier for this delta type. More... | |
object | NoChange [get] |
Returns a constant that indicates no changes between values. More... | |
The optional extension provided by IDataType implementations that support incremental changes to values.
Each implementation specifies a value type and a delta type. Two values, oldValue and newValue, can be compared to produce a delta using Diff(object,object). The delta can be separately applied to oldValue to create newValue using Apply(object,object).
Delta types should provide a string representation. Equality is optional for delta types.
Deferred parsing
Implementations can choose not to fully validate values when they are read, but instead defer parsing until it is required. Consequently, all methods that accept values can throw InvalidDataException.
Since 5.8
object PushTechnology.ClientInterface.Data.IDeltaType.Apply | ( | object | oldValue, |
object | delta | ||
) |
Applies a delta to a value.
oldValue | The old value object. |
delta | The delta object to apply to the old value object. |
object PushTechnology.ClientInterface.Data.IDeltaType.Diff | ( | object | oldValue, |
object | newValue | ||
) |
Creates a delta from two values.
If there are many differences between oldValue and newValue, the result might require more bytes to transmit than the new value, or be computationally expensive to apply. In this case, it is better to discard oldValue and publish newValue in its place. This can be checked using IsValueCheaper(object,object).
The implementation can return the special constant NoChange to indicate the oldValue and newValue are equivalent and there is no change to publish.
oldValue | The old value object. |
newValue | The new value object. |
bool PushTechnology.ClientInterface.Data.IDeltaType.IsValueCheaper | ( | object | value, |
object | delta | ||
) |
Calculates if value is cheaper than delta . The result is typically determined by the length of the serialized form but can also consider the complexity of the delta.
value | The value object. |
delta | The delta object. |
object PushTechnology.ClientInterface.Data.IDeltaType.ReadDelta | ( | byte[] | input, |
int | offset, | ||
int | length | ||
) |
Creates a delta from binary segment.
input | The binary data. The implementation may re-use the array to avoid copying. The caller must ensure the array is not modified. |
offset | The starting index of the segment. |
length | The length of the segment. |
Implemented in PushTechnology.ClientInterface.Data.IDeltaType< TValue, TDelta >.
object PushTechnology.ClientInterface.Data.IDeltaType.ReadDelta | ( | byte[] | input | ) |
Creates a delta from binary segment.
This is equivalent to ReadDelta(input,0,input.Length).
input | The binary data. The implementation may re-use the array to avoid copying. The caller must ensure the array is not modified. |
Implemented in PushTechnology.ClientInterface.Data.IDeltaType< TValue, TDelta >.
object PushTechnology.ClientInterface.Data.IDeltaType.ReadDelta | ( | IBytes | input | ) |
Creates a delta from IBytes.
This is equivalent to calling ReadDelta(byte[]) with the result of IBytes.ToByteArray as argument.
Since 6.0.
input | The binary data. |
Implemented in PushTechnology.ClientInterface.Data.IDeltaType< TValue, TDelta >.
IBytes PushTechnology.ClientInterface.Data.IDeltaType.ToBytes | ( | object | delta | ) |
void PushTechnology.ClientInterface.Data.IDeltaType.WriteDelta | ( | object | delta, |
Stream | outputStream | ||
) |
Serializes a delta to binary.
delta | The delta object. |
outputStream | The output stream. |
|
get |
Returns the external identifier for this delta type.
|
get |
Returns a constant that indicates no changes between values.
This constant is returned by Diff(object,object) to indicate oldValue and newValue are equivalent. The result is guaranteed to be equal only to itself.