/// <summary>
 /// Initializes a new instance of the <see cref="PipelineEventArgs"/> class.
 /// </summary>
 /// <param name="message">The pipe message.</param>
 /// <param name="pipeline">The pipeline.</param>
 /// <param name="pipeFilter">The pipe filter.</param>
 /// <param name="exception">The exception.</param>
 public PipelineEventArgs(PipeMessage message, Pipeline pipeline, IPipeFilter pipeFilter, Exception exception = null)
 {
     this.Message        = message;
     this.Pipeline       = pipeline;
     this.PipeFilter     = pipeFilter;
     this.InnerException = exception;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Removes the specified filter from the pipeline.
        /// </summary>
        /// <param name="filter">The filter to remove.</param>
        /// <returns>Current Pipeline instance.</returns>
        public Pipeline Unregister(IPipeFilter filter)
        {
            if (filter != null && this._filterChain.Contains(filter))
            {
                lock (Utilities.GetSyncRoot(this._filterChain))
                {
                    this._filterChain.Remove(filter);
                }
            }

            return(this);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Registers the specified filter to the pipeline.
        /// </summary>
        /// <param name="filter">The filter to add.</param>
        /// <returns>Current Pipeline instance.</returns>
        public Pipeline Register(IPipeFilter filter)
        {
            if (filter == null)
            {
                throw new ArgumentNullException("filter", "IPipeFilter instance cannot be null.");
            }

            lock (Utilities.GetSyncRoot(this._filterChain))
            {
                this._filterChain.Add(filter);
            }

            return(this);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Registers the specified filter to the pipeline.
        /// </summary>
        /// <param name="filter">The filter to add.</param>
        /// <param name="filterIndex">The filter at the specified index.</param>
        /// <returns>Current Pipeline instance.</returns>
        public Pipeline RegisterAt(IPipeFilter filter, int filterIndex)
        {
            if (filter == null)
            {
                throw new ArgumentNullException("filter", "IPipeFilter instance cannot be null.");
            }

            if (filterIndex < 0)
            {
                throw new ArgumentOutOfRangeException("filterIndex", "Index is less than 0.");
            }

            lock (Utilities.GetSyncRoot(this._filterChain))
            {
                if (filterIndex > this._filterChain.Count)
                {
                    filterIndex = this._filterChain.Count;
                }

                this._filterChain.Insert(filterIndex, filter);
            }

            return(this);
        }
Ejemplo n.º 5
0
 public void RegisterFilter(IPipeFilter <TInput, TModel, TAccumulator> filter)
 {
     Filters.Add(filter);
 }
Ejemplo n.º 6
0
 public FilterObserver(ILogic logic, IPipeFilter inPipeFilter, IPipeFilter outPipeFilter)
 {
     Logic = logic;
     InPipeFilter = inPipeFilter;
     OutPipeFilter = outPipeFilter;
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Method RaiseEvent.
        /// </summary>
        /// <param name="eventHandler">Instance of EventHandler.</param>
        /// <param name="message">The pipe message.</param>
        /// <param name="pipeFilter">The pipe filter.</param>
        /// <param name="exception">The exception.</param>
        private void RaiseEvent(EventHandler <PipelineEventArgs> eventHandler, PipeMessage message, IPipeFilter pipeFilter, Exception exception = null)
        {
            // Copy a reference to the delegate field now into a temporary field for thread safety.
            EventHandler <PipelineEventArgs> temp = Interlocked.CompareExchange(ref eventHandler, null, null);

            if (temp != null)
            {
                temp(this, new PipelineEventArgs(message, this, pipeFilter, exception));
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Occurs after the filter processed message.
 /// </summary>
 /// <param name="filter">The filter done processed message.</param>
 /// <param name="message">The output message.</param>
 protected virtual void AfterFilterProcessed(IPipeFilter filter, PipeMessage message)
 {
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Occurs before the filter processing message.
 /// </summary>
 /// <param name="filter">The filter going to process message.</param>
 /// <param name="message">The input message.</param>
 protected virtual void BeforeFilterProcessing(IPipeFilter filter, PipeMessage message)
 {
 }