Evento SyncCallbacks.ItemConstraint

Ocorre quando é relatado um conflito de restrição para conflitos de colisão quando a política de resolução de conflitos de colisão é definida como ApplicationDefined e para todos os conflitos de restrição de não colisão.

Namespace: Microsoft.Synchronization
Assembly: Microsoft.Synchronization (em microsoft.synchronization.dll)

Sintaxe

'Declaração
Public Event ItemConstraint As EventHandler(Of ItemConstraintEventArgs)
'Uso
Dim instance As SyncCallbacks
Dim handler As EventHandler(Of ItemConstraintEventArgs)

AddHandler instance.ItemConstraint, handler
public event EventHandler<ItemConstraintEventArgs> ItemConstraint
public:
event EventHandler<ItemConstraintEventArgs^>^ ItemConstraint {
    void add (EventHandler<ItemConstraintEventArgs^>^ value);
    void remove (EventHandler<ItemConstraintEventArgs^>^ value);
}
/** @event */
public void add_ItemConstraint (EventHandler<ItemConstraintEventArgs> value)

/** @event */
public void remove_ItemConstraint (EventHandler<ItemConstraintEventArgs> value)
JScript supports the use of events, but not the declaration of new ones.

Comentários

Essa notificação pode ser usada por um aplicativo para executar a resolução personalizada de conflito de restrição. Para isso, o aplicativo inspeciona e processa o conteúdo do objeto ItemConstraintEventArgs enviado para o manipulador de eventos e define a ação de resolução do conflito chamando SetResolutionAction antes de retornar desse método.

Quando a propriedade ConstraintConflictReason do objeto ItemConstraintEventArgs é definida como qualquer valor diferente de Collision, a ação de resolução deve ser definida como SkipChange ou SaveConflict.

Exemplo

O exemplo a seguir implementa um manipulador para o evento ItemConstraint. O manipulador exibe os itens conflitantes para o usuário e define a ação de resolução de conflito de restrição com base na resposta do usuário.

Private Sub HandleItemConstraint(ByVal sender As [Object], ByVal args As ItemConstraintEventArgs)
    If ConstraintConflictReason.Collision = args.ConstraintConflictReason Then
        ' Display the two items that are in conflict and solicit a resolution from the user.
        Dim srcContact As New Contact(DirectCast(args.SourceChangeData, String()))
        Dim destContact As New Contact(DirectCast(args.DestinationChangeData, String()))
        Dim msg As String = ("Source change is " & srcContact.ToString() & vbLf & "Destination change is ") & destContact.ToString() & vbLf & "Click Yes to rename the source change and apply it." & vbLf & "Click No to rename the destination item and apply the source change." & vbLf & "Click Cancel to delete the destination item and apply the source change."
        Dim ccDlg As New ConstraintConflictDlg(msg)
        ccDlg.ShowDialog()

        ' Set the resolution action based on the user's response.
        args.SetResolutionAction(ccDlg.Resolution)
    Else
        args.SetResolutionAction(ConstraintConflictResolutionAction.SaveConflict)
    End If
End Sub
void HandleItemConstraint(Object sender, ItemConstraintEventArgs args)
{
    if (ConstraintConflictReason.Collision == args.ConstraintConflictReason)
    {
        // Display the two items that are in conflict and solicit a resolution from the user.
        Contact srcContact = new Contact((string[])args.SourceChangeData);
        Contact destContact = new Contact((string[])args.DestinationChangeData);
        string msg = "Source change is " + srcContact.ToString() +
                   "\nDestination change is " + destContact.ToString() +
                   "\nClick Yes to rename the source change and apply it." +
                   "\nClick No to rename the destination item and apply the source change." +
                   "\nClick Cancel to delete the destination item and apply the source change.";
        ConstraintConflictDlg ccDlg = new ConstraintConflictDlg(msg);
        ccDlg.ShowDialog();

        // Set the resolution action based on the user's response.
        args.SetResolutionAction(ccDlg.Resolution);
    }
    else 
    {
        args.SetResolutionAction(ConstraintConflictResolutionAction.SaveConflict);
    }
}

Consulte também

Referência

Classe SyncCallbacks
Membros SyncCallbacks
Namespace Microsoft.Synchronization

Conceitos

Detectando e solucionando conflitos de restrição