LocalItemChange 类
表示对 EnumerateChanges 返回的本地副本中的项的变更。
命名空间: Microsoft.Synchronization.SimpleProviders
程序集: Microsoft.Synchronization.SimpleProviders(在 microsoft.synchronization.simpleproviders.dll 中)
语法
声明
Public Class LocalItemChange
用法
Dim instance As LocalItemChange
public class LocalItemChange
public ref class LocalItemChange
public class LocalItemChange
public class LocalItemChange
示例
下面的代码示例演示 EnumerateChanges 方法的实现,该方法适用于在内存内存储区中存储项的示例应用程序。LocalItemChange 对象用于将每个项自上一个定位点以来已更改的变更存储到存储区中。若要在完整应用程序的上下文中查看此代码,请参见"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.LocalItemChange
线程安全
此类型的所有公共静态(在 Visual Basic 中共享 )成员都是线程安全的。不保证任何实例成员的线程安全。
请参阅
参考
LocalItemChange 成员
Microsoft.Synchronization.SimpleProviders 命名空间