ItemConstraintEventArgs Class

Provides data for the ItemConstraint event.

Inheritance Hierarchy

System.Object
  System.EventArgs
    Microsoft.Synchronization.ItemConstraintEventArgs

Namespace:  Microsoft.Synchronization
Assembly:  Microsoft.Synchronization (in Microsoft.Synchronization.dll)

Syntax

'Declaration
Public Class ItemConstraintEventArgs _
    Inherits EventArgs
'Usage
Dim instance As ItemConstraintEventArgs
public class ItemConstraintEventArgs : EventArgs
public ref class ItemConstraintEventArgs : public EventArgs
type ItemConstraintEventArgs =  
    class
        inherit EventArgs
    end
public class ItemConstraintEventArgs extends EventArgs

The ItemConstraintEventArgs type exposes the following members.

Properties

  Name Description
Public property ConstraintConflictReason Gets the reason that the conflict occurred.
Public property DestinationChange Gets the change metadata from the destination provider.
Public property DestinationChangeData Gets an object that either contains or can be used to retrieve item data for the change item from the destination replica.
Public property DestinationOriginalChangeData Gets an object that either contains or can be used to retrieve item data for the item in the destination replica that originally caused the conflict.
Public property IsTemporary Gets a value that indicates whether the conflict is temporary.
Public property OriginalDestinationChange Gets the change metadata from the destination provider for the item that originally caused the conflict.
Public property SourceChange Gets the change metadata from the source provider.
Public property SourceChangeData Gets an object that either contains or can be used to retrieve item data for the change item from the source replica.

Top

Methods

  Name Description
Public method Equals (Inherited from Object.)
Protected method Finalize (Inherited from Object.)
Public method GetHashCode (Inherited from Object.)
Public method GetResolutionAction() Gets the conflict resolution action for the conflict.
Public method GetResolutionAction(ChangeUnitChange) Gets the conflict resolution action for the conflicting change unit change.
Public method GetType (Inherited from Object.)
Protected method MemberwiseClone (Inherited from Object.)
Public method SetResolutionAction(ConstraintConflictResolutionAction) Sets a conflict resolution action for the conflict.
Public method SetResolutionAction(ChangeUnitChange, ConstraintConflictResolutionAction) Sets a conflict resolution action for the conflicting change unit change.
Public method ToString (Inherited from Object.)

Top

Remarks

ItemConstraintEventArgs occurs when a constraint conflict is reported, for collision conflicts when the collision conflict resolution policy is set to ApplicationDefined, and for all non-collision constraint conflicts.

Examples

The following example implements a handler for the ItemConstraint event. The handler displays the conflicting items to the user and sets the constraint conflict resolution action based on the user's response.

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);
    }
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Microsoft.Synchronization Namespace

Other Resources

Handling Conflicts