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 命名空间