public INextHandler GetRunnerForPipeline(Type messageType)
        {
            var pipeline = pipelineBuilder.GetPipeline(messageType);

            if (!pipeline.HandlerTypes.Any())
            {
                return(NoHandlersForMessage(messageType));
            }

            return(new NextHandlerRunner(message => BuildNextHandler(pipeline.DelegatingHandlerTypes, pipeline.HandlerTypes).Handle(message)));
        }
Example #2
0
        public async Task <ProcessingResult> StartProcessing(Guid draftId, Reservation reservation)
        {
            _pipeline = _pipelineBuilder.GetPipeline(reservation, PaymentType.PayPal);

            _context = new ReservationProcessingContext()
            {
                Reservation = reservation,
                DraftId     = draftId
            };

            var first = _pipeline.FirstOrDefault();

            await RunAllMiddleware(first);

            return(_context.ProcessingResult ?? new ProcessingResult()
            {
                IsSuccess = true
            });
        }
Example #3
0
        public INextHandler GetRunnerForPipeline(Type messageType, CancellationToken cancellation)
        {
            if (cancellation == null)
            {
                throw new ArgumentNullException(nameof(cancellation));
            }

            var pipeline = pipelineBuilder.GetPipeline(messageType);

            if (!pipeline.HandlerTypes.Any())
            {
                return(NoHandlersForMessage(messageType, cancellation));
            }

            return(new NextHandlerRunner(message => {
                var firstHandler = BuildNextHandler(pipeline.DelegatingHandlerTypes, pipeline.HandlerTypes, cancellation);
                return firstHandler.Handle(message);
            }));
        }