private static void RaiseContractFailedEventImplementation(ContractFailureKind failureKind, string userMessage, string conditionText, Exception innerException, ref string resultFailureMessage) { if (failureKind < ContractFailureKind.Precondition || failureKind > ContractFailureKind.Assume) { throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", (object)failureKind), "failureKind"); } string str1 = "contract failed."; ContractFailedEventArgs e = (ContractFailedEventArgs)null; RuntimeHelpers.PrepareConstrainedRegions(); string str2; try { str1 = ContractHelper.GetDisplayMessage(failureKind, userMessage, conditionText); EventHandler <ContractFailedEventArgs> eventHandler = ContractHelper.contractFailedEvent; if (eventHandler != null) { e = new ContractFailedEventArgs(failureKind, str1, conditionText, innerException); foreach (EventHandler <ContractFailedEventArgs> invocation in eventHandler.GetInvocationList()) { try { invocation((object)null, e); } catch (Exception ex) { e.thrownDuringHandler = ex; e.SetUnwind(); } } if (e.Unwind) { if (Environment.IsCLRHosted) { ContractHelper.TriggerCodeContractEscalationPolicy(failureKind, str1, conditionText, innerException); } if (innerException == null) { innerException = e.thrownDuringHandler; } throw new ContractException(failureKind, str1, userMessage, conditionText, innerException); } } } finally { str2 = e == null || !e.Handled ? str1 : (string)null; } resultFailureMessage = str2; }
private static void RaiseContractFailedEventImplementation(ContractFailureKind failureKind, string userMessage, string conditionText, Exception innerException, ref string resultFailureMessage) { if (failureKind < ContractFailureKind.Precondition || failureKind > ContractFailureKind.Assume) { throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", new object[] { failureKind }), "failureKind"); } string text = "contract failed."; ContractFailedEventArgs contractFailedEventArgs = null; RuntimeHelpers.PrepareConstrainedRegions(); string text2; try { text = ContractHelper.GetDisplayMessage(failureKind, userMessage, conditionText); EventHandler <ContractFailedEventArgs> eventHandler = ContractHelper.contractFailedEvent; if (eventHandler != null) { contractFailedEventArgs = new ContractFailedEventArgs(failureKind, text, conditionText, innerException); foreach (EventHandler <ContractFailedEventArgs> eventHandler2 in eventHandler.GetInvocationList()) { try { eventHandler2(null, contractFailedEventArgs); } catch (Exception thrownDuringHandler) { contractFailedEventArgs.thrownDuringHandler = thrownDuringHandler; contractFailedEventArgs.SetUnwind(); } } if (contractFailedEventArgs.Unwind) { if (Environment.IsCLRHosted) { ContractHelper.TriggerCodeContractEscalationPolicy(failureKind, text, conditionText, innerException); } if (innerException == null) { innerException = contractFailedEventArgs.thrownDuringHandler; } throw new ContractException(failureKind, text, userMessage, conditionText, innerException); } } } finally { if (contractFailedEventArgs != null && contractFailedEventArgs.Handled) { text2 = null; } else { text2 = text; } } resultFailureMessage = text2; }