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
线程安全
此类型的所有公共静态(在 Visual Basic 中共享 )成员都是线程安全的。不保证任何实例成员的线程安全。
请参阅
参考
AnchorEnumerationContext 成员
Microsoft.Synchronization.SimpleProviders 命名空间