Пример #1
0
        private async Task SerializeHeaderAsync(Stream stream, IDiagnosticLogger?logger, CancellationToken cancellationToken = default)
        {
            var writer = new Utf8JsonWriter(stream);

#if NET461 || NETSTANDARD2_0
            using (writer)
#else
            await using (writer.ConfigureAwait(false))
#endif
            {
                writer.WriteDictionaryValue(Header, logger);
                await writer.FlushAsync(cancellationToken).ConfigureAwait(false);
            }
        }
Пример #2
0
        private static async Task SerializeHeaderAsync(
            Stream stream,
            IReadOnlyDictionary <string, object?> header,
            CancellationToken cancellationToken = default)
        {
            var writer = new Utf8JsonWriter(stream);

#if NET461 || NETSTANDARD2_0
            using (writer)
#else
            await using (writer.ConfigureAwait(false))
#endif
            {
                writer.WriteDictionaryValue(header);
                await writer.FlushAsync(cancellationToken).ConfigureAwait(false);
            }
        }