Freigeben über


AnchorEnumerationContext-Klasse

Der Synchronisierungssitzungskontext, der an ein AnchorEnumerationSimpleSyncProvider-Objekt übergeben wird.

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

Syntax

'Declaration
Public Class AnchorEnumerationContext
    Inherits ItemEnumerationContext
'Usage
Dim instance As AnchorEnumerationContext
public class AnchorEnumerationContext : ItemEnumerationContext
public ref class AnchorEnumerationContext : public ItemEnumerationContext
public class AnchorEnumerationContext extends ItemEnumerationContext
public class AnchorEnumerationContext extends ItemEnumerationContext

Hinweise

Der Kontext kann vom Anbieter verwendet werden, wenn der Anbieter keine Enumeration von Elementen zurückgibt, oder wenn er das Enumerationsverhalten der Sync Framework-Laufzeit ändern muss.

Beispiel

Das folgende Codebeispiel enthält das AnchorEnumerationContext-Objekt, das an die EnumerateChanges-Methode übergeben wird, sowie die ReportChanges-Methode, die für das Context-Objekt aufgerufen wird. In der "Sync101 using Simple Sync Provider"-Anwendung, die im Sync Framework SDK und in der Code Gallery verfügbar ist, finden Sie diesen Code im Kontext einer vollständigen Anwendung.

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

Vererbungshierarchie

System.Object
   Microsoft.Synchronization.SimpleProviders.ItemEnumerationContext
    Microsoft.Synchronization.SimpleProviders.AnchorEnumerationContext

Threadsicherheit

Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Siehe auch

Verweis

AnchorEnumerationContext-Member
Microsoft.Synchronization.SimpleProviders-Namespace