mirror of https://github.com/Squidex/squidex.git
committed by
GitHub
7 changed files with 10 additions and 52 deletions
@ -1,34 +0,0 @@ |
|||||
// ==========================================================================
|
|
||||
// Squidex Headless CMS
|
|
||||
// ==========================================================================
|
|
||||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|
||||
// All rights reserved. Licensed under the MIT license.
|
|
||||
// ==========================================================================
|
|
||||
|
|
||||
using GraphQL; |
|
||||
using Microsoft.AspNetCore.WebUtilities; |
|
||||
using Squidex.Infrastructure.Json; |
|
||||
|
|
||||
namespace Squidex.Domain.Apps.Entities.Contents.GraphQL |
|
||||
{ |
|
||||
public sealed class DefaultDocumentWriter : IDocumentWriter |
|
||||
{ |
|
||||
private readonly IJsonSerializer jsonSerializer; |
|
||||
|
|
||||
public DefaultDocumentWriter(IJsonSerializer jsonSerializer) |
|
||||
{ |
|
||||
this.jsonSerializer = jsonSerializer; |
|
||||
} |
|
||||
|
|
||||
public async Task WriteAsync<T>(Stream stream, T value, |
|
||||
CancellationToken cancellationToken = default) |
|
||||
{ |
|
||||
await using (var buffer = new FileBufferingWriteStream()) |
|
||||
{ |
|
||||
jsonSerializer.Serialize(value, buffer, true); |
|
||||
|
|
||||
await buffer.DrainBufferAsync(stream, cancellationToken); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
Loading…
Reference in new issue