Esempio n. 1
0
        public T Deserialize <T>(string contentType, byte[] value)
        {
            Check.NotNullOrWhiteSpace(contentType, nameof(contentType));
            Check.NotNull(value, nameof(value));

            IBrokerSerializer serializer = GetSerializer(contentType);

            return(serializer.Deserialize <T>(value, typeof(T)));
        }
Esempio n. 2
0
        public object Deserialize(string contentType, Type valueType, byte[] value)
        {
            Check.NotNullOrWhiteSpace(contentType, nameof(contentType));
            Check.NotNull(valueType, nameof(valueType));
            Check.NotNull(value, nameof(value));

            IBrokerSerializer serializer = GetSerializer(contentType);

            return(serializer.Deserialize(value, valueType));
        }
Esempio n. 3
0
        public IMessage Deserialize(Type messageType, BasicDeliverEventArgs deliveryEvent)
        {
            Check.NotNull(messageType, nameof(messageType));
            Check.NotNull(deliveryEvent, nameof(deliveryEvent));

            string contentType = deliveryEvent.BasicProperties.ContentType;

            if (contentType.IsNullOrWhiteSpace())
            {
                throw new BrokerException(
                          $"The content type for a message of type: {messageType} was not " +
                          $"specified as a basic property.");
            }

            IBrokerSerializer serializer = GetSerializer(contentType);

            return(serializer.Deserialize <IMessage>(deliveryEvent.Body, messageType));
        }