public static void ValidateReceiveWithReceive(Receive receive1, Receive receive2) { Fx.Assert(receive1 != null && receive2 != null, "Validation argument cannot be null!"); Fx.Assert(receive1.OperationName != null, "OperationName cannot be null in Receive"); string receiveOperationName = receive1.OperationName; if (receive1.Action != receive2.Action) { throw FxTrace.Exception.AsError(new ValidationException(SR2.TwoReceivesWithSameNameButDifferentAction(receiveOperationName))); } if (receive1.InternalContent is ReceiveMessageContent && receive2.InternalContent is ReceiveMessageContent) { ReceiveMessageContent receiveMessage1 = receive1.InternalContent as ReceiveMessageContent; ReceiveMessageContent receiveMessage2 = receive2.InternalContent as ReceiveMessageContent; ValidateReceiveWithReceive(receiveMessage1, receiveMessage2, receiveOperationName); } else if (receive1.InternalContent is ReceiveParametersContent && receive2.InternalContent is ReceiveParametersContent) { ReceiveParametersContent receiveParameters1 = receive1.InternalContent as ReceiveParametersContent; ReceiveParametersContent receiveParameters2 = receive2.InternalContent as ReceiveParametersContent; ValidateReceiveParametersWithReceiveParameters(receiveParameters1, receiveParameters2, receiveOperationName); } else { throw FxTrace.Exception.AsError(new ValidationException(SR2.ReceiveAndReceiveParametersHaveSameName(receiveOperationName))); } if (receive1.HasReply && receive2.HasReply) { ValidateSendReplyWithSendReply(receive1.FollowingReplies[0], receive2.FollowingReplies[0]); } else if ((receive1.HasReply || receive1.HasFault) != (receive2.HasReply || receive2.HasFault)) { throw FxTrace.Exception.AsError(new ValidationException(SR2.TwoReceivesWithSameNameButDifferentIsOneWay(receiveOperationName))); } if ((receive1.InternalReceive.AdditionalData.IsInsideTransactedReceiveScope != receive2.InternalReceive.AdditionalData.IsInsideTransactedReceiveScope) || (receive1.InternalReceive.AdditionalData.IsFirstReceiveOfTransactedReceiveScopeTree != receive2.InternalReceive.AdditionalData.IsFirstReceiveOfTransactedReceiveScopeTree)) { throw FxTrace.Exception.AsError(new ValidationException(SR2.TwoReceivesWithSameNameButDifferentTxProperties(receiveOperationName))); } }