ValueTask IDataTransferObject.WriteToAsync <TWriter>(TWriter writer, CancellationToken token) { Task result; if (touched) { result = Task.FromException(new InvalidOperationException(ExceptionMessages.ReadLogEntryTwice)); } else { touched = true; result = reader.CopyToAsync(writer, token); } return(new ValueTask(result)); }
ValueTask IDataTransferObject.WriteToAsync <TWriter>(TWriter writer, CancellationToken token) { ValueTask result; if (touched) { #if NETCOREAPP3_1 result = new (Task.FromException(new InvalidOperationException(ExceptionMessages.ReadLogEntryTwice))); #else result = ValueTask.FromException(new InvalidOperationException(ExceptionMessages.ReadLogEntryTwice)); #endif } else { touched = true; result = new(reader.CopyToAsync(writer, token)); } return(result); }
public override Task CopyToAsync(PipeWriter destination, CancellationToken cancellationToken = default) { _socketConnection.EnsureStarted(); return(_reader.CopyToAsync(destination, cancellationToken)); }
Task IAsyncBinaryWriter.CopyFromAsync(PipeReader input, CancellationToken token) => input.CopyToAsync(output, token);