Diffusion .NET Client Library  6.1.5
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
PushTechnology.ClientInterface.Data.IDeltaType Interface Reference

The optional extension provided by IDataType implementations that support incremental changes to values. More...

Inheritance diagram for PushTechnology.ClientInterface.Data.IDeltaType:
PushTechnology.ClientInterface.Data.IDeltaType< TValue, TDelta >

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

Detailed Description

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

Member Function Documentation

object PushTechnology.ClientInterface.Data.IDeltaType.Apply ( object  oldValue,
object  delta 
)

Applies a delta to a value.

Parameters
oldValueThe old value object.
deltaThe delta object to apply to the old value object.
Returns
The new value object. The old value object will be returned if the delta had no effect.
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.

Parameters
oldValueThe old value object.
newValueThe new value object.
Returns
The delta representing the difference between oldValue and newValue.
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.

Parameters
valueThe value object.
deltaThe delta object.
Returns
True if value is considered cheaper than delta . Otherwise false.
object PushTechnology.ClientInterface.Data.IDeltaType.ReadDelta ( byte[]  input,
int  offset,
int  length 
)

Creates a delta from binary segment.

Parameters
inputThe binary data. The implementation may re-use the array to avoid copying. The caller must ensure the array is not modified.
offsetThe starting index of the segment.
lengthThe length of the segment.
Returns
The delta object.

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).

Parameters
inputThe binary data. The implementation may re-use the array to avoid copying. The caller must ensure the array is not modified.
Returns
The delta object.

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.

Parameters
inputThe binary data.
Returns
The delta object.

Implemented in PushTechnology.ClientInterface.Data.IDeltaType< TValue, TDelta >.

IBytes PushTechnology.ClientInterface.Data.IDeltaType.ToBytes ( object  delta)

Returns the serialized form of the given delta as IBytes.

Since 6.0.

Parameters
deltaThe delta object.
Returns
The delta as IBytes.
void PushTechnology.ClientInterface.Data.IDeltaType.WriteDelta ( object  delta,
Stream  outputStream 
)

Serializes a delta to binary.

Parameters
deltaThe delta object.
outputStreamThe output stream.

Property Documentation

string PushTechnology.ClientInterface.Data.IDeltaType.Name
get

Returns the external identifier for this delta type.

object PushTechnology.ClientInterface.Data.IDeltaType.NoChange
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.


The documentation for this interface was generated from the following file: