AnchorEnumerationContext::ReportChanges Method
Reports the set of changes that were retrieved during a call to EnumerateChanges.
Assembly: Microsoft.Synchronization.SimpleProviders (in Microsoft.Synchronization.SimpleProviders.dll)
public: void ReportChanges( IEnumerable<LocalItemChange^>^ itemChanges, array<unsigned char>^ updatedAnchor )
Parameters
- itemChanges
- Type: System.Collections.Generic::IEnumerable<LocalItemChange>
A collection of LocalItemChange objects that contain metadata about changes to items in the local replica.
- updatedAnchor
- Type: array<System::Byte>
A byte array that represents an enumeration anchor, such as a timestamp.
| Exception | Condition |
|---|---|
| SimpleProviderInvalidOperationException | ReportItemsAndAutodetectDeletes was called in the same session. |
The following code example shows the AnchorEnumerationContext object being passed to the EnumerateChanges method, and the ReportChanges method being called on the context object. 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
Show: