/// <summary>
    /// Updates the pipeline element.
    /// </summary>
    /// <param name="pipelineElement">The pipeline element.</param>
    /// <param name="pipelineDefinition">The pipeline definition.</param>
    protected virtual void UpdatePipelineElement(XElement pipelineElement, PipelineDefinition pipelineDefinition)
    {
      IEnumerator<XElement> elementEnumerator = pipelineElement.Elements(ProcessorElementName).GetEnumerator();
      IEnumerator<ProcessorDefinition> processorEnumerator = pipelineDefinition.Processors.GetEnumerator();

      IDictionary<XElement, object> elementsToReplace = new Dictionary<XElement, object>();
      ICollection<XElement> elementsToRemove = new LinkedList<XElement>();
      ICollection<ProcessorDefinition> processorsToAdd = new LinkedList<ProcessorDefinition>();
      
      bool elementFlag, processorFlag;

      do
      {
        elementFlag = elementEnumerator.MoveNext();
        processorFlag = processorEnumerator.MoveNext();

        if (elementFlag && processorFlag)
        {
          elementsToReplace.Add(elementEnumerator.Current, processorEnumerator.Current.ProcessorElement);
        }
        else if (elementFlag)
        {
          elementsToRemove.Add(elementEnumerator.Current);
        }
        else if (processorFlag)
        {
          processorsToAdd.Add(processorEnumerator.Current);
        }
      }
      while (elementFlag || processorFlag);

      foreach (KeyValuePair<XElement, object> pair in elementsToReplace)
      {
        pair.Key.ReplaceWith(pair.Value);
      }

      foreach (XElement element in elementsToRemove)
      {
        element.Remove();
      }

      foreach (ProcessorDefinition processorDefinition in processorsToAdd)
      {
        pipelineElement.Add(this.MapProcessorToElement(processorDefinition));
      }
    }
    /// <summary>
    /// Maps the element to pipeline.
    /// </summary>
    /// <param name="pipelineName">Name of the pipeline.</param>
    /// <param name="pipelineDomain">The pipeline domain.</param>
    /// <param name="pipelineElement">The pipeline element.</param>
    /// <returns>PipelineDefinition instance created from pipeline element.</returns>
    protected virtual PipelineDefinition MapElementToPipeline(string pipelineName, string pipelineDomain, XElement pipelineElement)
    {
      PipelineDefinition pipelineDefinition = new PipelineDefinition(pipelineName, pipelineDomain);

      foreach (XElement processorElement in pipelineElement.Elements(ProcessorElementName))
      {
        pipelineDefinition.Processors.Add(this.MapElementToProcessor(processorElement));
      }

      return pipelineDefinition;
    }