public static void ValidateSendReplyWithSendReply(SendReply sendReply1, SendReply sendReply2) { Fx.Assert(sendReply1 != null && sendReply2 != null, "Validation argument cannot be null!"); Fx.Assert(sendReply1.Request != null, "Request cannot be null in SendReply"); string operationName = sendReply1.Request.OperationName; if (sendReply1.Action != sendReply2.Action) { throw FxTrace.Exception.AsError(new ValidationException(SR2.TwoSendRepliesWithSameNameButDifferentAction(operationName))); } if (sendReply1.InternalContent is SendMessageContent && sendReply2.InternalContent is SendMessageContent) { SendMessageContent sendMessage1 = sendReply1.InternalContent as SendMessageContent; SendMessageContent sendMessage2 = sendReply2.InternalContent as SendMessageContent; if (sendMessage1.InternalDeclaredMessageType != sendMessage2.InternalDeclaredMessageType) { throw FxTrace.Exception.AsError(new ValidationException(SR2.TwoSendRepliesWithSameNameButDifferentValueType(operationName))); } } else if (sendReply1.InternalContent is SendParametersContent && sendReply2.InternalContent is SendParametersContent) { SendParametersContent sendReplyParameters1 = sendReply1.InternalContent as SendParametersContent; SendParametersContent sendReplyParameters2 = sendReply2.InternalContent as SendParametersContent; int count = sendReplyParameters1.ArgumentNames.Length; if (count != sendReplyParameters2.ArgumentNames.Length) { throw FxTrace.Exception.AsError(new ValidationException(SR2.TwoSendReplyParametersWithSameNameButDifferentParameterCount(operationName))); } for (int i = 0; i < count; i++) { if (sendReplyParameters1.ArgumentNames[i] != sendReplyParameters2.ArgumentNames[i]) { throw FxTrace.Exception.AsError(new ValidationException(SR2.TwoSendReplyParametersWithSameNameButDifferentParameterName(operationName))); } if (sendReplyParameters1.ArgumentTypes[i] != sendReplyParameters2.ArgumentTypes[i]) { throw FxTrace.Exception.AsError(new ValidationException(SR2.TwoSendReplyParametersWithSameNameButDifferentParameterType(operationName))); } } } else { throw FxTrace.Exception.AsError(new ValidationException(SR2.ReceivePairedWithSendReplyAndSendReplyParameters(operationName))); } }