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
。
どんな洞察も大歓迎です!