Beispiel #1
0
        /// <summary>
        /// Create a pipeline for a channel
        /// </summary>
        /// <returns>Created pipeline</returns>
        public IPipeline Build()
        {
            var pipeline = new Pipeline();

            foreach (var handler in this.uptreamHandlers)
            {
                if (handler.Factory != null)
                {
                    pipeline.AddUpstreamHandler(handler.Factory());
                }
                else
                {
                    pipeline.AddUpstreamHandler(handler.Handler);
                }
            }
            foreach (var handler in this.downstreamHandlers)
            {
                if (handler.Factory != null)
                {
                    pipeline.AddDownstreamHandler(handler.Factory());
                }
                else
                {
                    pipeline.AddDownstreamHandler(handler.Handler);
                }
            }
            return(pipeline);
        }
Beispiel #2
0
        /// <summary>
        /// Create a pipeline for a channel
        /// </summary>
        /// <returns>Created pipeline</returns>
        public IPipeline Build()
        {
            var pipeline = new Pipeline();

            foreach (var handler in _uptreamHandlers)
            {
                if (handler.HandlerType != null)
                {
                    pipeline.AddUpstreamHandler((IUpstreamHandler)_serviceLocator.Resolve(handler.HandlerType));
                }
                else
                {
                    pipeline.AddUpstreamHandler(handler.Handler);
                }
            }
            foreach (var handler in _downstreamHandlers)
            {
                if (handler.HandlerType != null)
                {
                    pipeline.AddDownstreamHandler((IDownstreamHandler)_serviceLocator.Resolve(handler.HandlerType));
                }
                else
                {
                    pipeline.AddDownstreamHandler(handler.Handler);
                }
            }
            return(pipeline);
        }
 public void TestDownstreamOrder()
 {
     var pipeline = new Pipeline();
     pipeline.AddDownstreamHandler(new DownstreamOrderHandler(2));
     pipeline.AddDownstreamHandler(new DownstreamOrderHandler(1));
     pipeline.AddDownstreamHandler(new DownstreamOrderHandler(0));
     pipeline.SendDownstream(new MyMessage());
     Assert.Equal(-1, DownstreamOrderHandler.CurrentIndex);
 }
        public HttpListener(IPipelineFactory clientFactory)
        {
            _pipeline = new Pipeline();
            _pipeline.AddDownstreamHandler(this);
            _pipeline.AddUpstreamHandler(this);
            _serverChannel = new TcpServerChannel(_pipeline, clientFactory, 2000);

        }
 public void SendUpStreamAndSwitchToDown()
 {
     var pipeline = new Pipeline();
     IPipelineMessage downMsg = null;
     pipeline.AddUpstreamHandler(new MyUpHandler((ctx, m) =>
         {
             var upMsg = m;
             ctx.SendDownstream(upMsg);
         }));
     pipeline.AddDownstreamHandler(new MyDownHandler((ctx, m) => downMsg = m));
     pipeline.SendUpstream(new Disconnected(new Exception()));
     Assert.NotNull(downMsg);
 }