public IAsyncEnumerable <TResponse> Handle(
     TRequest request,
     CancellationToken cancellationToken,
     StreamHandlerDelegate <TResponse> next)
 {
     throw new NotSupportedException();
 }
Example #2
0
        public IAsyncEnumerable <TResponse> Handle(
            TRequest request,
            CancellationToken cancellationToken,
            StreamHandlerDelegate <TResponse> next)
        {
            _output.Messages.Add("StreamConstructorTestBehavior before");
#pragma warning disable CC0031 // Check for null before calling a delegate
            return(next());

#pragma warning restore CC0031 // Check for null before calling a delegate
        }
    public async IAsyncEnumerable <R> Handle(T request, [EnumeratorCancellation] CancellationToken cancellationToken, StreamHandlerDelegate <R> next)
    {
        if (_validator is not null)
        {
            var context = new ValidationContext <T>(request);

            var response = await _validator.ValidateAsync(context, cancellationToken).ConfigureAwait(false);

            if (!response.IsValid)
            {
                throw new ValidationException(response.Errors);
            }
        }

        await foreach (var item in next().WithCancellation(cancellationToken))
        {
            yield return(item);
        }
    }
Example #4
0
    public async IAsyncEnumerable <TResponse> Handle(TRequest request, [EnumeratorCancellation] CancellationToken cancellationToken, StreamHandlerDelegate <TResponse> next)
    {
        await _writer.WriteLineAsync("-- Handling StreamRequest");

        await foreach (var response in next().WithCancellation(cancellationToken).ConfigureAwait(false))
        {
            yield return(response);
        }
        await _writer.WriteLineAsync("-- Finished StreamRequest");
    }