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 執行階段的列舉行為。
範例
下列程式碼範例示範要傳遞給 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
繼承階層
System.Object
Microsoft.Synchronization.SimpleProviders.ItemEnumerationContext
Microsoft.Synchronization.SimpleProviders.AnchorEnumerationContext
執行緒安全性
任何公用靜態 (共用 在 Visual Basic) 此型別的成員具備執行緒安全。不保證任何執行個體成員安全執行緒。
請參閱
參考
AnchorEnumerationContext 成員
Microsoft.Synchronization.SimpleProviders 命名空間