共用方式為


AnchorEnumerationSimpleSyncProvider.EnumerateChanges 方法

在衍生類別中覆寫時,從複寫中列舉在指定之錨定值之後發生的變更。

命名空間: Microsoft.Synchronization.SimpleProviders
組件: Microsoft.Synchronization.SimpleProviders (在 microsoft.synchronization.simpleproviders.dll)

語法

'宣告
Public MustOverride Sub EnumerateChanges ( _
    anchor As Byte(), _
    context As AnchorEnumerationContext _
)
'用途
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
)

參數

  • anchor
    表示列舉錨定的位元組陣列,例如時間戳記。列舉在這個錨定之後發生的變更。如果錨定是 Null,提供者應該列舉存放區中的所有項目。
  • context
    AnchorEnumerationContext 物件,這個物件可讓您報告項目和變更,以及指定項目刪除的處理方式。

備註

這個方法應該包含或呼叫存放區專屬程式碼,讓 Sync Framework 列舉存放區中自所指定錨定之後已變更的所有項目的中繼資料。

範例

下列程式碼範例針對將項目儲存在記憶體中存放區的範例應用程式示範 EnumerateChanges 方法的實作。若要在完整應用程式的內容中檢視這段程式碼,請參閱 Sync Framework SDK 及 Code Gallery 中的 "Sync101 using Simple Sync Provider" 應用程式。

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

請參閱

參考

AnchorEnumerationSimpleSyncProvider 類別
AnchorEnumerationSimpleSyncProvider 成員
Microsoft.Synchronization.SimpleProviders 命名空間