Example #1
0
 /// <inheritdoc />
 public override CloudEvent DecodeStructuredModeMessage(ReadOnlyMemory <byte> body, ContentType?contentType, IEnumerable <CloudEventAttribute>?extensionAttributes)
 {
     return(DecodeStructuredModeMessage(BinaryDataUtilities.AsStream(body), contentType, extensionAttributes));
 }
        /// <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));
        }
        /// <summary>
        /// Decodes a CloudEvent from a structured-mode message body, represented as a stream. The default implementation asynchronously 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 CloudEvent derived from the structured data.</returns>
        public virtual async Task <CloudEvent> DecodeStructuredModeMessageAsync(Stream data, ContentType contentType, IEnumerable <CloudEventAttribute> extensionAttributes)
        {
            var bytes = await BinaryDataUtilities.ToByteArrayAsync(data).ConfigureAwait(false);

            return(DecodeStructuredModeMessage(bytes, contentType, extensionAttributes));
        }
        /// <summary>
        /// Asynchronously decodes a CloudEvent from a structured-mode message body, represented as a stream. The default implementation asynchronously copies the
        /// content of the stream into a read-only memory segment before passing it to <see cref="DecodeStructuredModeMessage(ReadOnlyMemory{byte}, ContentType, IEnumerable{CloudEventAttribute})"/>
        /// but this can be overridden by event formatters that can decode a stream more efficiently.
        /// </summary>
        /// <param name="body">The message body (content). 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 message body.</param>
        /// <param name="extensionAttributes">The extension attributes to use when populating the CloudEvent. May be null.</param>
        /// <returns>The CloudEvent derived from the structured message body.</returns>
        public virtual async Task <CloudEvent> DecodeStructuredModeMessageAsync(Stream body, ContentType?contentType, IEnumerable <CloudEventAttribute>?extensionAttributes)
        {
            var bytes = await BinaryDataUtilities.ToReadOnlyMemoryAsync(body).ConfigureAwait(false);

            return(DecodeStructuredModeMessage(bytes, contentType, extensionAttributes));
        }
        /// <summary>
        /// Decodes a CloudEvent from a structured-mode message body, represented as a stream. The default implementation copies the
        /// content of the stream into a read-only memory segment before passing it to <see cref="DecodeStructuredModeMessage(ReadOnlyMemory{byte}, ContentType, IEnumerable{CloudEventAttribute})"/>
        /// but this can be overridden by event formatters that can decode a stream more efficiently.
        /// </summary>
        /// <param name="messageBody">The message body (content). 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 message body.</param>
        /// <param name="extensionAttributes">The extension attributes to use when populating the CloudEvent. May be null.</param>
        /// <returns>The decoded CloudEvent.</returns>
        public virtual CloudEvent DecodeStructuredModeMessage(Stream messageBody, ContentType?contentType, IEnumerable <CloudEventAttribute>?extensionAttributes)
        {
            var bytes = BinaryDataUtilities.ToReadOnlyMemory(messageBody);

            return(DecodeStructuredModeMessage(bytes, contentType, extensionAttributes));
        }
        /// <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 read-only memory segment before passing it to <see cref="DecodeBatchModeMessage(ReadOnlyMemory{byte}, ContentType, IEnumerable{CloudEventAttribute})"/>
        /// but this can be overridden by event formatters that can decode a stream more efficiently.
        /// </summary>
        /// <param name="body">The message body (content). 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 message body.</param>
        /// <param name="extensionAttributes">The extension attributes to use when populating the CloudEvent. May be null.</param>
        /// <returns>The collection of CloudEvents derived from the batch message body.</returns>
        public virtual IReadOnlyList <CloudEvent> DecodeBatchModeMessage(Stream body, ContentType?contentType, IEnumerable <CloudEventAttribute>?extensionAttributes)
        {
            var bytes = BinaryDataUtilities.ToReadOnlyMemory(body);

            return(DecodeBatchModeMessage(bytes, contentType, extensionAttributes));
        }
Example #7
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));
        }
Example #8
0
        /// <summary>
        /// Asynchronously decodes a collection CloudEvents from a batch-mode message body, represented as a stream. The default implementation asynchronously 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="body">The message body (content). 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 message body.</param>
        /// <param name="extensionAttributes">The extension attributes to use when populating the CloudEvent. May be null.</param>
        /// <returns>The collection of CloudEvents derived from the batch message body.</returns>
        public virtual async Task <IReadOnlyList <CloudEvent> > DecodeBatchModeMessageAsync(Stream body, ContentType contentType, IEnumerable <CloudEventAttribute> extensionAttributes)
        {
            var bytes = await BinaryDataUtilities.ToByteArrayAsync(body).ConfigureAwait(false);

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