private Stream CreateJsonStream() { var cloudEvent = new CloudEvent { Data = new { DataName = "DataValue" } }.PopulateRequiredAttributes(); var bytes = new JsonEventFormatter().EncodeStructuredModeMessage(cloudEvent, out _); return(BinaryDataUtilities.AsStream(bytes)); }
/// <inheritdoc /> public override IReadOnlyList <CloudEvent> DecodeBatchModeMessage(ReadOnlyMemory <byte> body, ContentType?contentType, IEnumerable <CloudEventAttribute>?extensionAttributes) => DecodeBatchModeMessage(BinaryDataUtilities.AsStream(body), contentType, extensionAttributes);
private static HttpRequest CreateRequest(ReadOnlyMemory <byte> content, ContentType contentType) => new DefaultHttpRequest(new DefaultHttpContext()) { ContentType = contentType.ToString(), Body = BinaryDataUtilities.AsStream(content) };
/// <inheritdoc /> public override void DecodeBinaryModeEventData(ReadOnlyMemory <byte> body, CloudEvent cloudEvent) => cloudEvent.Data = body.Length == 0 ? null : s_jsonParser.Parse <T>(new StreamReader(BinaryDataUtilities.AsStream(body)));
/// <inheritdoc /> public override CloudEvent DecodeStructuredModeMessage(ReadOnlyMemory <byte> body, ContentType?contentType, IEnumerable <CloudEventAttribute>?extensionAttributes) => DecodeStructuredModeMessageImpl(BinaryDataUtilities.AsStream(body), contentType, extensionAttributes, false).GetAwaiter().GetResult();