/// <summary> /// Convenience method to serialize a JObject to bytes, then /// decode it as a structured event with a specialized formatter and no extension attributes. /// </summary> private static CloudEvent DecodeStructuredModeMessage(JObject obj) { byte[] bytes = Encoding.UTF8.GetBytes(obj.ToString()); var formatter = new SpecializedFormatter(); return(formatter.DecodeStructuredModeMessage(bytes, null, null)); }
/// <summary> /// Convenience method to format a CloudEvent with a specialized formatter in /// structured mode, then parse the result as a JObject. /// </summary> private static JsonElement EncodeAndParseStructured(CloudEvent cloudEvent) { var formatter = new SpecializedFormatter(); var encoded = formatter.EncodeStructuredModeMessage(cloudEvent, out _); return(JsonEventFormatterTest.ParseJson(encoded)); }