Condividi tramite


Metodo AnchorEnumerationSimpleSyncProvider.EnumerateChanges

Quando sottoposto a override in una classe derivata, enumera le modifiche da una replica che si è verificata a partire dal valore di ancoraggio specificato.

Spazio dei nomi: Microsoft.Synchronization.SimpleProviders
Assembly: Microsoft.Synchronization.SimpleProviders (in microsoft.synchronization.simpleproviders.dll)

Sintassi

'Dichiarazione
Public MustOverride Sub EnumerateChanges ( _
    anchor As Byte(), _
    context As AnchorEnumerationContext _
)
'Utilizzo
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
)

Parametri

  • anchor
    Matrice di byte che rappresenta un ancoraggio dell'enumerazione, ad esempio un timestamp. Le modifiche che si sono verificate a partire da questo ancoraggio vengono enumerate. Se l'ancoraggio è Null, il provider deve enumerare tutti gli elementi nell'archivio.
  • context
    Oggetto AnchorEnumerationContext che consente di segnalare elementi e modifiche e di specificare come vengono gestite le eliminazioni degli elementi.

Osservazioni

Questo metodo deve contenere o chiamare codice specifico dell'archivio che consente a Sync Framework di enumerare i metadati per tutti gli elementi nell'archivio che hanno subito modifiche dopo l'ancoraggio specificato.

Esempio

Nell'esempio di codice seguente viene illustrata un'implementazione del metodo EnumerateChanges per un'applicazione di esempio che archivia elementi in un archivio dati in memoria. Per visualizzare il codice nel contesto di un'applicazione completa, vedere l'applicazione "Sync101 using Simple Sync Provider" disponibile in Sync Framework SDK e in 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

Vedere anche

Riferimento

Classe AnchorEnumerationSimpleSyncProvider
Membri AnchorEnumerationSimpleSyncProvider
Spazio dei nomi Microsoft.Synchronization.SimpleProviders