Ejemplo n.º 1
0
 /// <summary>
 /// The the upstream handler that this handler will forward messages to
 /// </summary>
 /// <param name="up">upstream handler</param>
 public void SetUpstream(UpstreamContext up)
 {
     if (up == null)
     {
         throw new ArgumentNullException("up");
     }
     _up = up;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Sets the next upstream handler that this one will forward messages to
 /// </summary>
 /// <param name="next">The next.</param>
 public void SetNext(UpstreamContext next)
 {
     if (next == null)
     {
         throw new ArgumentNullException("next");
     }
     _next = next;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Register a upstream handler. 
        /// Upstream handlers should be registered from closest to the 
        /// command handler and finally the application handler (which should receive the error messages)
        /// </summary>
        /// <param name="handler">The handler.</param>
        public void RegisterUpstream(IUpstreamHandler handler)
        {
            if (handler == null) throw new ArgumentNullException("handler");

            var newContext = new UpstreamContext(handler);
            if (_upstreamHandlers.Count > 0)
                _upstreamHandlers[_upstreamHandlers.Count - 1].SetNext(newContext);
            
            _upstreamHandlers.Add(newContext);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Add a new upstream handler (handles failures which was detected when the command was traveling down to the command handler)
        /// </summary>
        /// <param name="context">Context for the handler</param>
        public void Add(UpstreamContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (_fixed)
            {
                throw new InvalidOperationException(
                          "The pipeline may not be modified after Start() has been called.");
            }

            _upstream.Add(context);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Register a upstream handler.
        /// Upstream handlers should be registered from closest to the
        /// command handler and finally the application handler (which should receive the error messages)
        /// </summary>
        /// <param name="handler">The handler.</param>
        public void RegisterUpstream(IUpstreamHandler handler)
        {
            if (handler == null)
            {
                throw new ArgumentNullException("handler");
            }

            var newContext = new UpstreamContext(handler);

            if (_upstreamHandlers.Count > 0)
            {
                _upstreamHandlers[_upstreamHandlers.Count - 1].SetNext(newContext);
            }

            _upstreamHandlers.Add(newContext);
        }
Ejemplo n.º 6
0
        public void DestinationIsNotSet()
        {
            var upContext = new UpstreamContext(new ForwardingUpHandler());
            var destination = Substitute.For<IUpstreamHandler>();
            var downHandler = Substitute.For<IDownstreamHandler>();
            var downContext = new DownstreamContext(downHandler);
            var pipeline = new Decoupled.Pipeline.Pipeline();
            var msg = Substitute.For<IUpstreamMessage>();

            pipeline.Add(downContext);
            pipeline.Add(upContext);
            pipeline.Add(new UpstreamContext(destination));
            pipeline.Start();
            upContext.Invoke(msg);

            destination.Received().HandleUpstream(Arg.Any<IUpstreamContext>(), msg);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Pipeline" /> class.
 /// </summary>
 public Pipeline()
 {
     _myUpContext = new UpstreamContext(this);
     _myDownContext = new DownstreamContext(this);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Add a new upstream handler (handles failures which was detected when the command was traveling down to the command handler)
        /// </summary>
        /// <param name="context">Context for the handler</param>
        public void Add(UpstreamContext context)
        {
            if (context == null) throw new ArgumentNullException("context");
            if (_fixed)
                throw new InvalidOperationException(
                    "The pipeline may not be modified after Start() has been called.");

            _upstream.Add(context);
        }
 /// <summary>
 /// The the upstream handler that this handler will forward messages to
 /// </summary>
 /// <param name="up">upstream handler</param>
 public void SetUpstream(UpstreamContext up)
 {
     if (up == null) throw new ArgumentNullException("up");
     _up = up;
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Pipeline" /> class.
 /// </summary>
 public Pipeline()
 {
     _myUpContext   = new UpstreamContext(this);
     _myDownContext = new DownstreamContext(this);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Sets the next upstream handler that this one will forward messages to
 /// </summary>
 /// <param name="next">The next.</param>
 public void SetNext(UpstreamContext next)
 {
     if (next == null) throw new ArgumentNullException("next");
     _next = next;
 }