private void AppendToPipeline(IEnumerable <RequestHandlerAttribute> attributes, IHandleRequests <TRequest> implicitHandler, IRequestContext requestContext) { IHandleRequests <TRequest> lastInPipeline = implicitHandler; attributes.Each((attribute) => { var decorator = new HandlerFactory <TRequest>(attribute, _handlerFactory, requestContext).CreateRequestHandler(); lastInPipeline.SetSuccessor(decorator); lastInPipeline = decorator; }); }
private void AppendToPipeline(IEnumerable <RequestHandlerAttribute> attributes, IHandleRequests <TRequest> implicitHandler, IRequestContext requestContext) { IHandleRequests <TRequest> lastInPipeline = implicitHandler; attributes.Each(attribute => { var handlerType = attribute.GetHandlerType(); if (handlerType.GetTypeInfo().GetInterfaces().Contains(typeof(IHandleRequests))) { var decorator = new HandlerFactory <TRequest>(attribute, _handlerFactory, requestContext).CreateRequestHandler(); lastInPipeline.SetSuccessor(decorator); lastInPipeline = decorator; } else { var message = string.Format("All handlers in a pipeline must derive from IHandleRequests. You cannot have a mixed pipeline by including handler {0}", handlerType.Name); throw new ConfigurationException(message); } }); }