LocalItemChange Class

Represents a change to an item in the local replica that is returned by EnumerateChanges(array<Byte[], AnchorEnumerationContext, array<Byte[]%).

Inheritance Hierarchy

System.Object
  Microsoft.Synchronization.SimpleProviders.LocalItemChange

Namespace:  Microsoft.Synchronization.SimpleProviders
Assembly:  Microsoft.Synchronization.SimpleProviders (in Microsoft.Synchronization.SimpleProviders.dll)

Syntax

'Declaration
Public Class LocalItemChange
'Usage
Dim instance As LocalItemChange
public class LocalItemChange
public ref class LocalItemChange
type LocalItemChange =  class end
public class LocalItemChange

The LocalItemChange type exposes the following members.

Constructors

  Name Description
Public method LocalItemChange Initializes a new instance of the LocalItemChange class that contains the item key and version, and the type of change to the item.

Top

Properties

  Name Description
Public property KeyAndVersion Returns the key and version that identify the changed item.
Public property LocalItemChangeType Returns a LocalItemChangeType enumeration value that specifies whether an item was created, updated, or deleted.

Top

Methods

  Name Description
Public method Equals (Inherited from Object.)
Protected method Finalize (Inherited from Object.)
Public method GetHashCode (Inherited from Object.)
Public method GetType (Inherited from Object.)
Protected method MemberwiseClone (Inherited from Object.)
Public method ToString (Inherited from Object.)

Top

Examples

The following code example shows an implementation of the EnumerateChanges method for a sample application that stores items in an in-memory store. The LocalItemChange object is used to store the change for each item in the store that has changed since the last anchor. To view this code in the context of a complete application, see the "Sync101 using Simple Sync Provider" application that is available in the Sync Framework SDK and from Code Gallery.

public override void EnumerateChanges(byte[] anchor, AnchorEnumerationContext context)
{
    List<LocalItemChange> itemChanges = new List<LocalItemChange>();

    int startIndex = -1;

    if (anchor != null)
    {
        startIndex = _store.Changes.IndexOfKey(BitConverter.ToUInt64(anchor, 0));
    }

    for (int i = startIndex + 1; i < _store.Changes.Count; i++)
    {
        itemChanges.Add(_store.Changes.Values[i]);
    }

    // If the anchor is corrupt or out of date we could revert back to 
    // full enumeration mode for this session, and enumerate all items. 
    // This is done by calling context.ReportItemsAndAutodetectDeletes.
    context.ReportChanges(itemChanges, _store.GetAnchor());
}
Public Overrides Sub EnumerateChanges(ByVal anchor As Byte(), ByVal context As AnchorEnumerationContext)
    Dim itemChanges As New List(Of LocalItemChange)()

    Dim startIndex As Integer = -1

    If anchor IsNot Nothing Then
        startIndex = _store.Changes.IndexOfKey(BitConverter.ToUInt64(anchor, 0))
    End If

    For i As Integer = startIndex + 1 To _store.Changes.Count - 1
        itemChanges.Add(_store.Changes.Values(i))
    Next

    ' If the anchor is corrupt or out of date we could revert back to 
    ' full enumeration mode for this session, and enumerate all items. 
    ' This is done by calling context.ReportItemsAndAutodetectDeletes. 
    context.ReportChanges(itemChanges, _store.GetAnchor())
End Sub

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Microsoft.Synchronization.SimpleProviders Namespace