Example #1
0
 public static async ValueTask <byte[]> ToArrayAsync(
     this IStreamProducer producer,
     int copyBufferSize = StreamConsumer.DefaultBufferSize,
     CancellationToken cancellationToken = default)
 {
     await using var consumer = StreamConsumer.ToArray(copyBufferSize);
     return(await producer.ConsumeAsync(consumer, cancellationToken).ConfigureAwait(false));
 }
Example #2
0
 public static async ValueTask <string> ToStringAsync(
     this IStreamProducer producer,
     Encoding?encoding  = default,
     int copyBufferSize = StreamConsumer.DefaultBufferSize,
     CancellationToken cancellationToken = default)
 {
     await using var consumer = StreamConsumer.ToString(encoding, copyBufferSize);
     return(await producer.ConsumeAsync(consumer, cancellationToken).ConfigureAwait(false));
 }
Example #3
0
        public Streamer(IStreamProducer producer, IStreamConsumer consumer, CancellationToken cancellationToken)
        {
            var options     = new PipeOptions(minimumSegmentSize: 8 * 1024);
            var triggerSize = Math.Min(options.Pool.MaxBufferSize, options.MinimumSegmentSize);
            var pipe        = new Pipe(options);

            ConsumerCancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
            Producer = producer ?? throw new ArgumentNullException(nameof(producer));
            Consumer = consumer ?? throw new ArgumentNullException(nameof(consumer));
            Writer   = new PipeWriterWrapper <Streamer>(pipe.Writer, triggerSize, ProductionStartedCallback, WriterCompletionCallback, this);
            Reader   = pipe.Reader;
        }
 public ProducerSource(IStreamProducer producer)
 => _producer = producer ?? throw new ArgumentNullException(nameof(producer));
 public ChainedProducer(IStreamProducer producer, IStreamTransformation transformation)
 {
     _producer       = producer ?? throw new ArgumentNullException(nameof(producer));
     _transformation = transformation ?? throw new ArgumentNullException(nameof(transformation));
 }
Example #6
0
 ResizeOperationContext(MediaTypeHeaderValue contentType, IStreamProducer producer, IImageDestination?destination)
 {
     ContentType = contentType;
     Producer    = producer;
     Destination = destination;
 }
Example #7
0
 public static ResizeOperationContext Json(IStreamProducer producer, IImageDestination?destination = default)
 => new ResizeOperationContext(_json, producer, destination);
Example #8
0
 public static ResizeOperationContext Inline(IStreamProducer producer, IImageDestination destination)
 => new ResizeOperationContext(_binary, producer, destination);
 AnalyzeOperationContext(MediaTypeHeaderValue contentType, IStreamProducer producer)
 {
     ContentType = contentType ?? throw new ArgumentNullException(nameof(contentType));
     Producer    = producer ?? throw new ArgumentNullException(nameof(producer));
 }
 public static AnalyzeOperationContext Json(IStreamProducer producer)
 => new AnalyzeOperationContext(_json, producer);
 public static AnalyzeOperationContext Inline(IStreamProducer producer)
 => new AnalyzeOperationContext(_binary, producer);