Exemplo n.º 1
0
 /// <summary>
 /// Will execute the given pipeline item starting with the filter at the filter index.
 /// </summary>
 /// <param name="filterIndex">The index of the filter to start process.</param>
 /// <param name="pipelineItem">The pipeline item to process.</param>
 /// <returns>The processed pipeline item.</returns>
 public IPipelineItem Execute(int filterIndex, IPipelineItem pipelineItem)
 {
     if ((filterIndex < 0) || (filterIndex >= _Filters.Count))
     {
         throw new ArgumentOutOfRangeException(("filterIndex"));
     }
     if (pipelineItem == null)
     {
         throw new ArgumentNullException("pipelineItem", "Parameter pipelineItem cannot be null.");
     }
     for (int index = filterIndex; index < _Filters.Count; index++)
     {
         RaisePreProcessFilterEvent(pipelineItem, index);
         if (pipelineItem.ContinueProcessing)
         {
             try
             {
                 pipelineItem = _Filters[index].Process(pipelineItem);
             }
             catch (Exception ex)
             {
                 RaiseExceptionEvent(this, new ExceptionEventArgs(pipelineItem, index, _Filters[index].Name, ex));
                 break;
             }
         }
         else
         {
             break;
         }
     }
     return(pipelineItem);
 }
Exemplo n.º 2
0
 public void Add(IPipelineItem item)
 {
     if (!this.addedItems.Contains(item.GetType()))
     {
         this.items.Add(item);
         this.addedItems.Add(item.GetType());
     }
 }
Exemplo n.º 3
0
 public void Add(IPipelineItem item)
 {
     if (!this.addedItems.Contains(item.GetType()))
     {
         this.items.Add(item);
         this.addedItems.Add(item.GetType());
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Will execute the given pipeline item starting with the first filter.
 /// </summary>
 /// <param name="pipelineItem">The pipeline item to process.</param>
 /// <returns>The processed pipeline item.</returns>
 public IPipelineItem Execute(IPipelineItem pipelineItem)
 {
     if (pipelineItem == null)
     {
         throw new ArgumentNullException("pipelineItem", "Parameter pipelineItem cannot be null.");
     }
     return(Execute(0, pipelineItem));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the ExceptionEventArgs class.
 /// </summary>
 /// <param name="pipelineItem">The pipeline item being processed when the exception occurred.</param>
 /// <param name="filterIndex">The index of the filter that was processing the <paramref name="pipelineItem"/>.</param>
 /// <param name="filterName">The name of the filter that was processing the <paramref name="pipelineItem"/>.</param>
 /// <param name="ex">The exception.</param>
 public ExceptionEventArgs(IPipelineItem pipelineItem,
                           int filterIndex,
                           string filterName,
                           Exception ex)
     : this()
 {
     PipelineItem = pipelineItem ?? throw new ArgumentNullException(nameof(pipelineItem));
     FilterIndex  = filterIndex;
     FilterName   = filterName;
     Exception    = ex;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the PreProcessFilterEventArgs class.
 /// </summary>
 /// <param name="pipelineItem">The pipeline item about to be processed.</param>
 /// <param name="filterIndex">The ordinal index of the filter about to be executed.</param>
 /// <param name="filterName">The name of the filter about to be executed.</param>
 public PreProcessFilterEventArgs(IPipelineItem pipelineItem,
                                  int filterIndex,
                                  string filterName)
     : this()
 {
     if (string.IsNullOrWhiteSpace(filterName))
     {
         throw new ArgumentNullException(nameof(filterName));
     }
     PipelineItem = pipelineItem ?? throw new ArgumentNullException(nameof(pipelineItem));
     FilterIndex  = filterIndex;
     FilterName   = filterName;
 }
Exemplo n.º 7
0
        /// <summary>
        /// Will execute the given pipeline item starting with the named filter.
        /// </summary>
        /// <param name="filterName">The name of the filter to start processing.</param>
        /// <param name="pipelineItem">The pipeline item to process.</param>
        /// <returns>The processed pipeline item.</returns>
        public IPipelineItem Execute(string filterName, IPipelineItem pipelineItem)
        {
            if (string.IsNullOrWhiteSpace(filterName))
            {
                throw new ArgumentNullException("filterName", "Parameter filterName cannot be null or empty.");
            }
            if (pipelineItem == null)
            {
                throw new ArgumentNullException("pipelineItem", "Parameter pipelineItem cannot be null.");
            }
            int filterIndex = FindFilterIndexByName(filterName);

            if (filterIndex != -1)
            {
                return(Execute(filterIndex, pipelineItem));
            }
            else
            {
                throw new ArgumentException(string.Format("The named filter ({0}) cannot be found.", filterName), "filterName");
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// Executes the pipeline step
 /// </summary>
 /// <param name="item">The pipeline item</param>
 /// <returns>The output queue to use</returns>
 internal override string Run(IPipelineItem item)
 {
     item = Function.Invoke(item);
     return(OutputQNames[0]);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Takes a pipeline item, processes it (possibly transforming it), and then returns it.
 /// </summary>
 /// <param name="pipelineItem">The pipeline item to process.</param>
 /// <returns>The processed pipeline item.</returns>
 public abstract IPipelineItem Process(IPipelineItem pipelineItem);
Exemplo n.º 10
0
 private void RaisePreProcessFilterEvent(IPipelineItem pipelineItem, int index)
 {
     PreProcessFilterEvent?.Invoke(this, new PreProcessFilterEventArgs(pipelineItem, index, _Filters[index].Name));
 }
Exemplo n.º 11
0
 /// <summary>
 /// Executes the pipeline step
 /// </summary>
 /// <param name="item">The pipeline item</param>
 /// <returns>The output queue to use</returns>
 internal override string Run(IPipelineItem item)
 {
     return(Function.Invoke(item));
 }
Exemplo n.º 12
0
 /// <summary>
 /// Executes the pipeline step
 /// </summary>
 /// <param name="item">The pipeline item</param>
 /// <returns>The output queue to use</returns>
 internal abstract string Run(IPipelineItem item);