AnchorEnumerationContext.SetDeleteMode 方法
设置删除是传播到其他副本的普通删除还是仅本地删除。
命名空间: Microsoft.Synchronization.SimpleProviders
程序集: Microsoft.Synchronization.SimpleProviders(在 microsoft.synchronization.simpleproviders.dll 中)
语法
声明
Public Overrides Sub SetDeleteMode ( _
deleteMode As SimpleSyncProviderDeleteMode _
)
用法
Dim instance As AnchorEnumerationContext
Dim deleteMode As SimpleSyncProviderDeleteMode
instance.SetDeleteMode(deleteMode)
public override void SetDeleteMode (
SimpleSyncProviderDeleteMode deleteMode
)
public:
virtual void SetDeleteMode (
SimpleSyncProviderDeleteMode deleteMode
) override
public void SetDeleteMode (
SimpleSyncProviderDeleteMode deleteMode
)
public override function SetDeleteMode (
deleteMode : SimpleSyncProviderDeleteMode
)
参数
- deleteMode
一个 SimpleSyncProviderDeleteMode 枚举值,指定删除是传播到其他副本的普通删除还是仅本地删除。
备注
某些同步方案要求能够删除位于本地副本的项并且不将该删除传播到其他副本。例如,一个服务器可能与存储不同销售人员的信息的若干设备同步。每个设备的空间都有限,因此销售人员从设备中删除已完成的旧订单。这些类型的删除不应传播到服务器,因为服务器仍要求此数据。通过简单提供程序,您可以指定数据只应本地删除。要在每个会话的基础上控制删除的行为,请通过使用此方法指定相应的选项。
示例
下面的代码示例指定在同步过程中不应传播删除。
public override void EnumerateChanges(byte[] anchor, AnchorEnumerationContext context)
{
context.SetDeleteMode(SimpleSyncProviderDeleteMode.LocalOnly);
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 override void EnumerateChanges(byte[] anchor, AnchorEnumerationContext context)
{
context.SetDeleteMode(SimpleSyncProviderDeleteMode.LocalOnly);
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());
}
请参阅
参考
AnchorEnumerationContext 类
AnchorEnumerationContext 成员
Microsoft.Synchronization.SimpleProviders 命名空间