Export (0) Print
Expand All

AnchorEnumerationContext Class

Sync Framework 2.0

The synchronization session context that is passed to an AnchorEnumerationSimpleSyncProvider object.

Namespace: Microsoft.Synchronization.SimpleProviders
Assembly: Microsoft.Synchronization.SimpleProviders (in microsoft.synchronization.simpleproviders.dll)

public class AnchorEnumerationContext : ItemEnumerationContext
public class AnchorEnumerationContext extends ItemEnumerationContext
public class AnchorEnumerationContext extends ItemEnumerationContext

The context can be used by the provider in circumstances when the provider is not going to return an enumeration of items or where the provider needs to modify the enumeration behavior of the Sync Framework runtime.

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

    // 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());


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