Класс AnchorEnumerationContext

Контекст сеанса синхронизации, переданный объекту AnchorEnumerationSimpleSyncProvider.

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

Синтаксис

'Декларация
Public Class AnchorEnumerationContext
    Inherits ItemEnumerationContext
'Применение
Dim instance As AnchorEnumerationContext
public class AnchorEnumerationContext : ItemEnumerationContext
public ref class AnchorEnumerationContext : public ItemEnumerationContext
public class AnchorEnumerationContext extends ItemEnumerationContext
public class AnchorEnumerationContext extends ItemEnumerationContext

Замечания

Контекст может использоваться поставщиком в тех случаях, когда он не собирается возвращать перечисление элементов или ему необходимо изменить поведение перечисления в среде выполнения Sync Framework.

Пример

В следующем примере кода показана передача объекта 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

Иерархия наследования

System.Object
   Microsoft.Synchronization.SimpleProviders.ItemEnumerationContext
    Microsoft.Synchronization.SimpleProviders.AnchorEnumerationContext

Многопоточное использование

Все общие статические члены (Shared в Visual Basic) можно использовать в многопоточных операциях. Безопасная многопоточная работа с членами экземпляров типа не гарантируется.

См. также

Справочник

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