Exemplo n.º 1
0
        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;
            });
        }
Exemplo n.º 2
0
        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);
                }
            });
        }