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