コード例 #1
0
        public static async Task <TMessage> GetDeserializedMessageAsync <TMessage>(this Stream stream, CancellationToken cancellationToken)
            where TMessage : class
        {
            var message = await stream.ReadMessageAsync(cancellationToken).ConfigureAwait(false);

            return(BinaryMessageSerializer.Deserialize <TMessage>(message));
        }
コード例 #2
0
        public void The_binary_formatter_should_make_mouths_happy()
        {
            byte[] serializedMessageData;

            IMessageSerializer serializer = new BinaryMessageSerializer();

            using (MemoryStream output = new MemoryStream())
            {
                serializer.Serialize(output, _message);

                serializedMessageData = output.ToArray();
            }

            using (MemoryStream input = new MemoryStream(serializedMessageData))
            {
                SerializationTestMessage receivedMessage = serializer.Deserialize(input) as SerializationTestMessage;

                Assert.AreEqual(_message, receivedMessage);
            }
        }
コード例 #3
0
        public void The_binary_formatter_should_make_mouths_happy()
        {
            byte[] serializedMessageData;

            IMessageSerializer serializer = new BinaryMessageSerializer();

            using (MemoryStream output = new MemoryStream())
            {
                serializer.Serialize(output, _message);

                serializedMessageData = output.ToArray();
            }

            using (MemoryStream input = new MemoryStream(serializedMessageData))
            {
                SerializationTestMessage receivedMessage = serializer.Deserialize(input) as SerializationTestMessage;

                Assert.AreEqual(_message, receivedMessage);
            }
        }