共用方式為


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

範例

下列程式碼範例示範要傳遞給 EnumerateChanges 方法的 AnchorEnumerationContext 物件,以及在內容物件上呼叫的 ReportChanges 方法。若要在完整應用程式的內容中檢視這段程式碼,請參閱 Sync Framework SDK 及 Code Gallery 中的 "Sync101 using Simple Sync Provider" 應用程式。

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