ItemConstraintEventArgs クラス

ItemConstraint イベントのデータを提供します。

名前空間: Microsoft.Synchronization
アセンブリ: Microsoft.Synchronization (microsoft.synchronization.dll 内)

構文

'宣言
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 名前空間

概念

競合の処理