다음을 통해 공유


ItemConstraintEventArgs 클래스

ItemConstraint 이벤트에 대한 데이터를 제공합니다.

네임스페이스: Microsoft.Synchronization
어셈블리: microsoft.synchronization.dll의 Microsoft.Synchronization

구문

‘선언
Public Class ItemConstraintEventArgs
    Inherits EventArgs
‘사용 방법
Dim instance As ItemConstraintEventArgs
public class ItemConstraintEventArgs : EventArgs
public ref class ItemConstraintEventArgs : public EventArgs
public class ItemConstraintEventArgs extends EventArgs
public class ItemConstraintEventArgs extends EventArgs

주의

중복 충돌 해결 정책이 ApplicationDefined로 설정된 중복 충돌 및 모든 비중복 제약 조건 충돌에 대해 제약 조건 충돌이 보고될 때 ItemConstraintEventArgs가 발생합니다.

예제

다음 예제에서는 ItemConstraint 이벤트에 대한 처리기를 구현합니다. 이 처리기는 사용자에게 충돌 항목을 표시하고 사용자의 응답에 따라 제약 조건 충돌 해결 동작을 설정합니다.

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

상속 계층 구조

System.Object
   System.EventArgs
    Microsoft.Synchronization.ItemConstraintEventArgs

스레드로부터의 안전성

이 유형의 모든 public static(Visual Basic의 경우 Shared ) 멤버는 스레드로부터 안전합니다. 인스턴스 멤버는 스레드로부터의 안전성이 보장되지 않습니다.

참고 항목

참조

ItemConstraintEventArgs 멤버
Microsoft.Synchronization 네임스페이스

개념

충돌 처리