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


Метод AnchorEnumerationContext.ReportChanges

Возвращает набор изменений, полученных при вызове метода EnumerateChanges.

Пространство имен: Microsoft.Synchronization.SimpleProviders
Сборка: Microsoft.Synchronization.SimpleProviders (в microsoft.synchronization.simpleproviders.dll)

Синтаксис

'Декларация
Public Sub ReportChanges ( _
    itemChanges As IEnumerable(Of LocalItemChange), _
    updatedAnchor As Byte() _
)
'Применение
Dim instance As AnchorEnumerationContext
Dim itemChanges As IEnumerable(Of LocalItemChange)
Dim updatedAnchor As Byte()

instance.ReportChanges(itemChanges, updatedAnchor)
public void ReportChanges (
    IEnumerable<LocalItemChange> itemChanges,
    byte[] updatedAnchor
)
public:
void ReportChanges (
    IEnumerable<LocalItemChange^>^ itemChanges, 
    array<unsigned char>^ updatedAnchor
)
public void ReportChanges (
    IEnumerable<LocalItemChange> itemChanges, 
    byte[] updatedAnchor
)
public function ReportChanges (
    itemChanges : IEnumerable<LocalItemChange>, 
    updatedAnchor : byte[]
)

Параметры

  • itemChanges
    Коллекция объектов LocalItemChange, содержащих метаданные изменения для элементов локальной реплики.
  • updatedAnchor
    Байтовый массив, который представляет привязку перечисления (например, отметку времени).

Исключения

Тип исключения Условие

SimpleProviderInvalidOperationException

В том же сеансе был вызван метод ReportItemsAndAutodetectDeletes.

Пример

В следующем примере кода показана передача объекта AnchorEnumerationContext методу EnumerateChanges и вызов метода ReportChanges для объекта контекста. Чтобы просмотреть этот код в контексте полного приложения, см. приложение "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

См. также

Справочник

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