Ejemplo n.º 1
0
 /// <summary>
 /// Replaces a pre processor type with another at the same index
 /// </summary>
 /// <typeparam name="TRemove"></typeparam>
 /// <typeparam name="TAdd"></typeparam>
 /// <param name="pipeline"></param>
 /// <param name="pipelineFactory"></param>
 /// <returns></returns>
 public static PreProcessPipeline Replace <TRemove, TAdd>(this PreProcessPipeline pipeline, PreProcessPipelineFactory pipelineFactory)
     where TRemove : IPreProcessor
     where TAdd : IPreProcessor
 {
     for (int i = 0; i < pipeline.Processors.Count; i++)
     {
         if (pipeline.Processors[i].GetType() == typeof(TRemove))
         {
             pipeline.Processors.RemoveAt(i);
             pipeline.Processors.Insert(i, pipelineFactory.Resolve <TAdd>());
         }
     }
     return(pipeline);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Resolves an instance of a pre processor based on type
 /// </summary>
 /// <returns></returns>
 public static IPreProcessor Resolve <T>(this PreProcessPipelineFactory pipelineFactory)
     where T : IPreProcessor
 {
     return(pipelineFactory.Resolve(typeof(T)));
 }