Share via


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 名前空間