/// <summary> /// Set down stream end point /// </summary> /// <param name="handler"> </param> public void SetChannel(IDownstreamHandler handler) { if (handler == null) throw new ArgumentNullException("handler"); _downStreamEndPoint = handler; _channelContext = new PipelineDownstreamContext(this, _downStreamEndPoint); _downstreamContexts.Last.Value.NextHandler = _channelContext; }
/// <summary> /// Initializes a new instance of the <see cref="DownstreamContext" /> class. /// </summary> /// <param name="mine">The mine.</param> public DownstreamContext(IDownstreamHandler mine) { if (mine == null) { throw new ArgumentNullException("mine"); } _mine = mine; }
/// <summary> /// Use an inversion of control container to find the dispatchers. /// </summary> /// <param name="rootContainer">Container adapter.</param> /// <returns>this</returns> public EventPipelineBuilder UseContainer(IRootContainer rootContainer) { if (rootContainer == null) { throw new ArgumentNullException("rootContainer"); } _inner = new IocHandler(rootContainer); return(this); }
/// <summary> /// Add a dispatcher which actually dispatches the commands. /// </summary> /// <param name="lastHandler">Last handler in the pipeline. Should invoke the correct command handler.</param> public PipelineDispatcherBuilder Dispatcher(IDownstreamHandler lastHandler) { if (lastHandler == null) { throw new ArgumentNullException("lastHandler"); } _lastHandler = lastHandler; return(this); }
/// <summary> /// Use a custom dispatcher for identifying the subscribers. /// </summary> /// <param name="dispatcher">Custom dispatcher. </param> /// <returns>this</returns> /// <remarks>The events are sent in the <see cref="DispatchEvent"/> message, so just check the message variable in <see cref="IDownstreamHandler.HandleDownstream"/> method after that.</remarks> public EventPipelineBuilder UseCustomDispatcher(IDownstreamHandler dispatcher) { if (dispatcher == null) { throw new ArgumentNullException("dispatcher"); } _inner = dispatcher; return(this); }
public void RegisterDownstreamHandler(IDownstreamHandler handler) { if (handler == null) throw new ArgumentNullException("handler"); if (handler is IChannel) throw new InvalidOperationException( "Channels will be registered by the framework, do not add them to the pipeline"); _downstreamHandlers.AddLast(handler); }
/// <summary> /// Register a downstream handler. Should start with the handler closest to the application and end with the handler which actually dispatches the message to the command handler. /// </summary> /// <param name="handler">The handler</param> public void RegisterDownstream(IDownstreamHandler handler) { if (handler == null) throw new ArgumentNullException("handler"); var newContext = new DownstreamContext(handler); if (_downstreamHandlers.Count > 0) _downstreamHandlers[_downstreamHandlers.Count - 1].SetNext(newContext); _downstreamHandlers.Add(newContext); }
/// <summary> /// Set down stream end point /// </summary> /// <param name="handler"> </param> public void SetChannel(IDownstreamHandler handler) { if (handler == null) { throw new ArgumentNullException("handler"); } _downStreamEndPoint = handler; _channelContext = new PipelineDownstreamContext(this, _downStreamEndPoint); _downstreamContexts.Last.Value.NextHandler = _channelContext; }
/// <summary> /// Register a downstream handler. Should start with the handler closest to the application and end with the handler which actually dispatches the message to the command handler. /// </summary> /// <param name="handler">The handler</param> public void RegisterDownstream(IDownstreamHandler handler) { if (handler == null) { throw new ArgumentNullException("handler"); } var newContext = new DownstreamContext(handler); if (_downstreamHandlers.Count > 0) { _downstreamHandlers[_downstreamHandlers.Count - 1].SetNext(newContext); } _downstreamHandlers.Add(newContext); }
/// <summary> /// Add a new downstream handler /// </summary> /// <param name="handler">Handler to add</param> /// <remarks>Downstream handlers takes care of everything sent from the client to the channel.</remarks> public void AddDownstreamHandler(IDownstreamHandler handler) { // always link with channel handler (will be replaced when the pipe is filled with more handlers // so that only the last handler has the channel as NextHandler). var ctx = new PipelineDownstreamContext(this, handler) {NextHandler = _channelContext}; var last = _downstreamContexts.Last; if (last != null) { _logger.Debug("Added downstream handler " + handler + " and linked it as next handler for " + last.Value); last.Value.NextHandler = ctx; } else { _logger.Debug("Added downstream handler " + handler); } _downstreamContexts.AddLast(ctx); }
/// <summary> /// Add a new downstream handler /// </summary> /// <param name="handler">Handler to add</param> /// <remarks>Downstream handlers takes care of everything sent from the client to the channel.</remarks> public void AddDownstreamHandler(IDownstreamHandler handler) { // always link with channel handler (will be replaced when the pipe is filled with more handlers // so that only the last handler has the channel as NextHandler). var ctx = new PipelineDownstreamContext(this, handler) { NextHandler = _channelContext }; var last = _downstreamContexts.Last; if (last != null) { _logger.Debug("Added downstream handler " + handler + " and linked it as next handler for " + last.Value); last.Value.NextHandler = ctx; } else { _logger.Debug("Added downstream handler " + handler); } _downstreamContexts.AddLast(ctx); }
/// <summary> /// Add an handler instance (singleton) /// </summary> /// <param name="handler">Must implement <see cref="IDownstreamHandler"/> and/or <see cref="IUpstreamHandler"/></param> /// <remarks>Same instance will be used for all channels. Use the <see cref="IPipelineHandlerContext"/> to store any context information.</remarks> public void AddDownstreamHandler(IDownstreamHandler handler) { this.downstreamHandlers.AddLast(new HandlerInformation <IDownstreamHandler>(handler)); }
public void SetChannel(IDownstreamHandler handler) { }
/// <summary> /// Initializes a new instance of the <see cref="DownstreamContext" /> class. /// </summary> /// <param name="mine">The mine.</param> public DownstreamContext(IDownstreamHandler mine) { if (mine == null) throw new ArgumentNullException("mine"); _mine = mine; }
public PipelineDownstreamContext(IPipeline pipeline, IDownstreamHandler myHandler) { _pipeline = pipeline; _myHandler = myHandler; }
/// <summary> /// Add a dispatcher which actually dispatches the commands. /// </summary> /// <param name="lastHandler">Last handler in the pipeline. Should invoke the correct command handler.</param> public PipelineDispatcherBuilder Dispatcher(IDownstreamHandler lastHandler) { if (lastHandler == null) throw new ArgumentNullException("lastHandler"); _lastHandler = lastHandler; return this; }
/// <summary> /// Use an inversion of control container to find the dispatchers. /// </summary> /// <param name="rootContainer">Container adapter.</param> /// <returns>this</returns> public EventPipelineBuilder UseContainer(IRootContainer rootContainer) { if (rootContainer == null) throw new ArgumentNullException("rootContainer"); _inner = new IocHandler(rootContainer); return this; }
/// <summary> /// Use a custom dispatcher for identifying the subscribers. /// </summary> /// <param name="dispatcher">Custom dispatcher. </param> /// <returns>this</returns> /// <remarks>The events are sent in the <see cref="DispatchEvent"/> message, so just check the message variable in <see cref="IDownstreamHandler.HandleDownstream"/> method after that.</remarks> public EventPipelineBuilder UseCustomDispatcher(IDownstreamHandler dispatcher) { if (dispatcher == null) throw new ArgumentNullException("dispatcher"); _inner = dispatcher; return this; }
public PipelineDownstreamContext(IPipeline pipeline, IDownstreamHandler myHandler) { this.pipeline = pipeline; this.myHandler = myHandler; }
/// <summary> /// Send a message down stream (from application to channel) /// </summary> /// <param name="handler">Handler to start with</param> /// <param name="channelEvent">Event to send</param> /// <remarks> /// All handlers above the specified one will be ignored and not invoked. /// </remarks> public void SendDownstream(IDownstreamHandler handler, IChannelEvent channelEvent) { ChannelHandlerContext ctx = _contexts[handler]; handler.HandleDownstream(ctx, channelEvent); }