GetPayload() public method

Gets the payload of the message.
public GetPayload ( ) : byte[]
return byte[]
示例#1
0
        private Task ProcessIncomingMessage(MessageReceivedEventArgs e)
        {
            try
            {
                var expected = this.logReader.GetPayload();

                // We're converting to XML and back again to normalize the payload. This could be done much more
                // efficiently by a dedicated method, which has yet to be implemented.
                var actualXml = this.ToXml(e.GetPayload());
                var actual    = this.FromXml(actualXml);

                if (!expected.SequenceEqual(actual))
                {
                    var msg         = "The expected payload does not match the actual received payload, see Data for details.";
                    var expectedXml = this.ToXml(expected);
                    throw new S101Exception(msg)
                          {
                              Data = { { "Expected", expectedXml }, { "Actual", actualXml } }
                          };
                }
            }
            catch (Exception ex)
            {
                this.done.TrySetException(ex);
                return(Task.FromResult(false));
            }

            return(this.SendMessagesAsync());
        }
示例#2
0
        private Task ProcessIncomingMessage(MessageReceivedEventArgs e)
        {
            try
            {
                var expected = this.logReader.GetPayload();

                // We're converting to XML and back again to normalize the payload. This could be done much more
                // efficiently by a dedicated method, which has yet to be implemented.
                var actualXml = this.ToXml(e.GetPayload());
                var actual = this.FromXml(actualXml);

                if (!expected.SequenceEqual(actual))
                {
                    var msg = "The expected payload does not match the actual received payload, see Data for details.";
                    var expectedXml = this.ToXml(expected);
                    throw new S101Exception(msg) { Data = { { "Expected", expectedXml }, { "Actual", actualXml } } };
                }
            }
            catch (Exception ex)
            {
                this.done.TrySetException(ex);
                return Task.FromResult(false);
            }

            return this.SendMessagesAsync();
        }