共用方式為


ConstraintConflictReason 列舉型別

表示可能會發生條件約束衝突的原因。

命名空間:  Microsoft.Synchronization
組件:  Microsoft.Synchronization (在 Microsoft.Synchronization.dll 中)

語法

'宣告
Public Enumeration ConstraintConflictReason
'用途
Dim instance As ConstraintConflictReason
public enum ConstraintConflictReason
public enum class ConstraintConflictReason
type ConstraintConflictReason
public enum ConstraintConflictReason

成員

成員名稱 描述
Other 項目或變更單位違反目的地複寫的其他條件約束。提供者可以選擇性地將發生衝突的項目識別碼指定為發生衝突的項目識別碼。
Collision 此項目因為與存放區中的其他項目發生衝突而無法儲存,例如,擁有與現有項目相同的名稱。提供者必須將目的地項目的識別碼指定為發生衝突的項目識別碼。
NoParent 此項目因為需要不存在於存放區中的父項目而無法存在階層資料存放區中。提供者可以選擇性地將遺漏父項目的識別碼指定為發生衝突的項目識別碼。
Identity 來源複寫與目的地複寫的項目識別碼不符。例如,複寫 X 會合併項目並將 id1 指派給合併的項目,藉以解決識別碼為 id1 和 id2 之項目間的衝突。複寫 Y 會重新命名 id1 所識別的項目並同時保留兩個項目,藉以解決識別碼為 id1 和 id2 之項目間的衝突。複寫 X 會傳送 id1 所識別之合併的項目,以及指出 id2 已合併到 id1 中的合併標記。系統會在 id1 上偵測到衝突,並當做並行衝突解決。系統會在 id2 上偵測到衝突,並透過指定 Identity 的衝突原因,將同步處理應用程式回報為識別碼衝突。應用程式會決定是透過保留來源變更還是目的地變更來解決衝突。

備註

目的地提供者會在回報條件約束衝突給變更套用者時,使用 ConstraintConflictReason 的成員來指定條件約束衝突的原因。如需條件約束衝突的詳細資訊,請參閱偵測及解決條件約束衝突

範例

下列範例會偵測新建立的項目是否會導致條件約束衝突,並且在發生衝突時傳回正確的條件約束衝突原因。

Public Function CanCreateContact(ByVal itemChange As ItemChange, ByVal changeData As String(), ByRef reason As ConstraintConflictReason, ByRef conflictingItemId As SyncId) As Boolean
    Dim canCreate As Boolean = True

    ' Create a temporary contact and see if its index values conflict with any item already in the contact store.
    Dim newContact As New Contact(changeData)
    canCreate = Not DetectIndexCollision(newContact, conflictingItemId)
    If Not canCreate Then
        ' An index collision occurred, so report a collision conflict.
        reason = ConstraintConflictReason.Collision
    Else
        ' This value won't be used because canCreate is set to true in this case.
        reason = ConstraintConflictReason.Other
    End If

    Return canCreate
End Function
public bool CanCreateContact(ItemChange itemChange, string[] changeData, out ConstraintConflictReason reason, out SyncId conflictingItemId)
{
    bool canCreate = true;

    // Create a temporary contact and see if its index values conflict with any item already in the contact store.
    Contact newContact = new Contact(changeData);
    canCreate = !DetectIndexCollision(newContact, out conflictingItemId);
    if (!canCreate)
    {
        // An index collision occurred, so report a collision conflict.
        reason = ConstraintConflictReason.Collision;
    }
    else
    {
        // This value won't be used because canCreate is set to true in this case.
        reason = ConstraintConflictReason.Other;
    }

    return canCreate;
}

請參閱

參考

Microsoft.Synchronization 命名空間