private IHandleRequestsAsync <TRequest> PushOntoAsyncPipeline(IEnumerable <RequestHandlerAttribute> attributes, IHandleRequestsAsync <TRequest> lastInPipeline, IRequestContext requestContext, bool continueOnCapturedContext) { attributes.Each(attribute => { var handlerType = attribute.GetHandlerType(); if (handlerType.GetTypeInfo().GetInterfaces().Contains(typeof(IHandleRequestsAsync))) { var decorator = new AsyncHandlerFactory <TRequest>(attribute, _asyncHandlerFactory, requestContext).CreateAsyncRequestHandler(); decorator.ContinueOnCapturedContext = continueOnCapturedContext; decorator.SetSuccessor(lastInPipeline); lastInPipeline = decorator; } else { var message = string.Format("All handlers in an async pipeline must derive from IHandleRequestsAsync. You cannot have a mixed pipeline by including handler {0}", handlerType.Name); throw new ConfigurationException(message); } }); return(lastInPipeline); }
private void AppendToAsyncPipeline(IEnumerable <RequestHandlerAttribute> attributes, IHandleRequestsAsync <TRequest> implicitHandler, IRequestContext requestContext) { IHandleRequestsAsync <TRequest> lastInPipeline = implicitHandler; attributes.Each(attribute => { var handlerType = attribute.GetHandlerType(); if (handlerType.GetTypeInfo().GetInterfaces().Contains(typeof(IHandleRequestsAsync))) { var decorator = new AsyncHandlerFactory <TRequest>(attribute, _asyncHandlerFactory, requestContext).CreateAsyncRequestHandler(); lastInPipeline.SetSuccessor(decorator); lastInPipeline = decorator; } else { var message = string.Format("All handlers in an async pipeline must derive from IHandleRequestsAsync. You cannot have a mixed pipeline by including handler {0}", handlerType.Name); throw new ConfigurationException(message); } }); }