Поделиться через


Метод 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 для образца приложения, сохраняющего элементы в хранилище данных в памяти. Чтобы просмотреть этот код в контексте полного приложения, см. приложение "Sync101 using Simple Sync Provider", которое можно найти в пакете Sync Framework SDK или на странице 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

См. также

Справочник

Класс AnchorEnumerationSimpleSyncProvider
Элементы AnchorEnumerationSimpleSyncProvider
Пространство имен Microsoft.Synchronization.SimpleProviders