/// <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); }
/// <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 TestUpstreamOrder() { var pipeline = new Pipeline(); pipeline.AddUpstreamHandler(new UpstreamOrderHandler(0)); pipeline.AddUpstreamHandler(new UpstreamOrderHandler(1)); pipeline.AddUpstreamHandler(new UpstreamOrderHandler(2)); pipeline.SendUpstream(new MyMessage()); Assert.Equal(3, UpstreamOrderHandler.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); }