/// <summary>
        /// Asynchronously decodes a CloudEvent from a structured-mode message body, represented as a stream. The default implementation copies the
        /// content of the stream into a byte array before passing it to <see cref="DecodeStructuredModeMessage(byte[], ContentType, IEnumerable{CloudEventAttribute})"/>
        /// but this can be overridden by event formatters that can decode a stream more efficiently.
        /// </summary>
        /// <param name="data">The data within the message body. Must not be null.</param>
        /// <param name="contentType">The content type of the message, or null if no content type is known.
        /// Typically this is a content type with a media type of "application/cloudevents"; the additional
        /// information such as the charset parameter may be needed in order to decode the data.</param>
        /// <param name="extensions">The extension attributes to use when populating the CloudEvent. May be null.</param>
        /// <returns>The decoded CloudEvent.</returns>
        public virtual CloudEvent DecodeStructuredModeMessage(Stream data, ContentType contentType, IEnumerable <CloudEventAttribute> extensionAttributes)
        {
            var bytes = BinaryDataUtilities.ToByteArray(data);

            return(DecodeStructuredModeMessage(bytes, contentType, extensionAttributes));
        }
Exemple #2
0
        /// <summary>
        /// Decodes a collection CloudEvents from a batch-mode message body, represented as a stream. The default implementation copies the
        /// content of the stream into a byte array before passing it to <see cref="DecodeBatchModeMessage(byte[], ContentType, IEnumerable{CloudEventAttribute})"/>
        /// but this can be overridden by event formatters that can decode a stream more efficiently.
        /// </summary>
        /// <param name="data">The data within the message body. Must not be null.</param>
        /// <param name="contentType">The content type of the message, or null if no content type is known.
        /// Typically this is a content type with a media type with a prefix of "application/cloudevents"; the additional
        /// information such as the charset parameter may be needed in order to decode the data.</param>
        /// <param name="extensions">The extension attributes to use when populating the CloudEvent. May be null.</param>
        /// <returns>The collection of CloudEvents derived from the batched data.</returns>
        public virtual IReadOnlyList <CloudEvent> DecodeBatchModeMessage(Stream data, ContentType contentType, IEnumerable <CloudEventAttribute> extensionAttributes)
        {
            var bytes = BinaryDataUtilities.ToByteArray(data);

            return(DecodeBatchModeMessage(bytes, contentType, extensionAttributes));
        }