Класс 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
type ItemConstraintEventArgs =
class
inherit EventArgs
end
public class ItemConstraintEventArgs extends EventArgs
Замечания
ItemConstraintEventArgs происходит при получении сообщения о конфликте ограничений применительно к конфликтам совпадения, если политика устранения конфликтов совпадения установлена в значение ApplicationDefined, и применительно ко всем остальным конфликтам ограничений, отличным от конфликтов совпадения.
Примеры
В следующем примере реализуется обработчик для события 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
Потоковая защита
Все открытые статический (Shared в Visual Basic) элементы этого типа потокобезопасны. Потокобезопасность элементов экземпляров не гарантируется.
См. также
Справочник
Элементы ItemConstraintEventArgs
Пространство имен Microsoft.Synchronization