我已经实现了一个FullEnumerationSimpleSyncProvider
似乎没有处理冲突的方法。
在构造函数中,我设置了以下属性:
this.Configuration.CollisionConflictResolutionPolicy = CollisionConflictResolutionPolicy.ApplicationDefined;
this.Configuration.ConflictResolutionPolicy = ConflictResolutionPolicy.ApplicationDefined;
this.ItemConstraint += new EventHandler<SimpleSyncItemConstraintEventArgs>(OnItemConstraint);
this.ItemConflicting += new EventHandler<SimpleSyncItemConflictingEventArgs>(OnItemConflicting);
我的约束和冲突事件处理程序:
void OnItemConstraint(object sender, SimpleSyncItemConstraintEventArgs e)
{
e.SetResolutionAction(ConstraintConflictResolutionAction.Merge);
}
void OnItemConflicting(object sender, SimpleSyncItemConflictingEventArgs e)
{
e.SetResolutionAction(ConflictResolutionAction.Merge);
}
但是,当我在 InsertItem() 中报告冲突时,永远不会调用约束/冲突事件处理程序。
public override void InsertItem(
object itemData,
IEnumerable<SyncId> changeUnitsToCreate,
RecoverableErrorReportingContext recoverableErrorReportingContext,
out ItemFieldDictionary keyAndUpdatedVersion,
out bool commitKnowledgeAfterThisItem) {
// ...snip...
// Check if it is already there --- name collision
if (itemAlreadyExists)
{
recoverableErrorReportingContext.RecordConstraintError(ConstructDictionary(item.ID));
keyAndUpdatedVersion = null;
commitKnowledgeAfterThisItem = false;
return;
}
// ...snip...
}
我想在调用同步框架时会在退出RecordConstraintError
后调用适当的事件处理程序。InsertItem
任何见解将不胜感激!