Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
When overridden in a derived class, enumerates changes from a replica that occurred since the specified anchor value.
Namespace: Microsoft.Synchronization.SimpleProviders
Assembly: Microsoft.Synchronization.SimpleProviders (in microsoft.synchronization.simpleproviders.dll)
Syntax
'Declaration
Public MustOverride Sub EnumerateChanges ( _
anchor As Byte(), _
context As AnchorEnumerationContext _
)
'Usage
Dim instance As AnchorEnumerationSimpleSyncProvider
Dim anchor As Byte()
Dim context As AnchorEnumerationContext
instance.EnumerateChanges(anchor, context)
public abstract void EnumerateChanges (
byte[] anchor,
AnchorEnumerationContext context
)
public:
virtual void EnumerateChanges (
array<unsigned char>^ anchor,
AnchorEnumerationContext^ context
) abstract
public abstract void EnumerateChanges (
byte[] anchor,
AnchorEnumerationContext context
)
public abstract function EnumerateChanges (
anchor : byte[],
context : AnchorEnumerationContext
)
Parameters
- anchor
A byte array that represents an enumeration anchor, such as a timestamp. Changes that occurred since this anchor are enumerated. If the anchor is null, the provider should enumerate all items in the store.
- context
An AnchorEnumerationContext object that enables you to report items and changes, and to specify how item deletes are handled.
Remarks
This method should contain or call store-specific code that enables Sync Framework to enumerate the metadata for all of the items in the store that have changed since the specified anchor.
Example
The following code example shows an implementation of the EnumerateChanges method for a sample application that stores items in an in-memory store. 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
See Also
Reference
AnchorEnumerationSimpleSyncProvider Class
AnchorEnumerationSimpleSyncProvider Members
Microsoft.Synchronization.SimpleProviders Namespace