Επεξεργασία

Κοινή χρήση μέσω


ContractHelper.RaiseContractFailedEvent Method

Definition

Used by the binary rewriter to activate the default failure behavior.

public:
 static System::String ^ RaiseContractFailedEvent(System::Diagnostics::Contracts::ContractFailureKind failureKind, System::String ^ userMessage, System::String ^ conditionText, Exception ^ innerException);
public static string RaiseContractFailedEvent (System.Diagnostics.Contracts.ContractFailureKind failureKind, string userMessage, string conditionText, Exception innerException);
static member RaiseContractFailedEvent : System.Diagnostics.Contracts.ContractFailureKind * string * string * Exception -> string
Public Shared Function RaiseContractFailedEvent (failureKind As ContractFailureKind, userMessage As String, conditionText As String, innerException As Exception) As String

Parameters

failureKind
ContractFailureKind

The type of failure.

userMessage
String

Additional user information.

conditionText
String

The description of the condition that caused the failure.

innerException
Exception

The inner exception that caused the current exception.

Returns

A null reference (Nothing in Visual Basic) if the event was handled and should not trigger a failure; otherwise, returns the localized failure message.

Exceptions

failureKind is not a valid ContractFailureKind value.

Remarks

The binary rewriter calls this method to notify listeners about a contract failure. The RaiseContractFailedEvent method does not perform the failure behavior (an assert or throw) itself. If the failure is handled by the listeners, the method returns null. If the failure is not handled by the listeners, a localized failure message is returned.

Applies to