AnchorEnumerationSimpleSyncProvider.EnumerateChanges-Methode
Listet, wenn in einer abgeleiteten Klasse überschrieben, Änderungen eines Replikats auf, die seit dem angegebenen Ankerwert aufgetreten sind.
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
)
Parameter
- anchor
Ein Bytearray, das einen Enumerationsanker darstellt, z. B. einen Timestamp. Änderungen, die seit diesem Anker aufgetreten sind, werden aufgezählt. Wenn der Anker NULL ist, sollte der Anbieter alle Elemente im Speicher auflisten.
- context
Ein AnchorEnumerationContext-Objekt, mit dem Sie Elemente und Änderungen melden können. Außerdem können Sie damit angeben, wie Elementlöschvorgänge bearbeitet werden.
Hinweise
Diese Methode sollte speicherspezifischen Code enthalten oder aufrufen, mithilfe dessen Sync Framework die Metadaten für alle Elemente auflisten kann, die seit dem angegebenen Anker geändert wurden.
Beispiel
Im folgenden Codebeispiel wird eine Implementierung der EnumerateChanges-Methode für eine Beispielanwendung gezeigt, die Elemente in einem Speicher im Arbeitsspeicher speichert. 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
Siehe auch
Verweis
AnchorEnumerationSimpleSyncProvider-Klasse
AnchorEnumerationSimpleSyncProvider-Member
Microsoft.Synchronization.SimpleProviders-Namespace