/// <summary> /// Inserts an existing pipeline before an existing named pipeline. /// </summary> /// <param name="pipelines">The pipeline collection.</param> /// <param name="target">The pipeline before which the specified pipeline should be inserted.</param> /// <param name="pipeline">The pipeline to insert.</param> /// <returns>The inserted pipeline.</returns> public static IPipeline InsertBefore(this IPipelineCollection pipelines, string target, IPipeline pipeline) { int index = pipelines.IndexOf(target); if (index < 0) { throw new KeyNotFoundException($"Target pipeline {target} was not found"); } return(pipelines.Insert(index, pipeline)); }
/// <summary> /// Inserts an existing pipeline after an existing named pipeline. /// </summary> /// <param name="pipelines">The pipeline collection.</param> /// <param name="target">The pipeline after which the specified pipeline should be inserted.</param> /// <param name="pipeline">The pipeline to insert.</param> /// <returns>The inserted pipeline.</returns> public static IPipeline InsertAfter(this IPipelineCollection pipelines, string target, IPipeline pipeline) { int index = pipelines.IndexOf(target); if (index < 0) { throw new KeyNotFoundException($"Target pipeline {target} was not found"); } return(index + 1 < pipelines.Count ? pipelines.Insert(index + 1, pipeline) : pipelines.Add(pipeline)); }
/// <summary> /// Inserts a new named pipeline into the collection. /// </summary> /// <param name="pipelines">The pipeline collection.</param> /// <param name="index">The index at which to insert the new pipeline.</param> /// <param name="name">The name of the new pipeline.</param> /// <param name="modules">The modules the new pipeline should contain.</param> /// <returns>The newly inserted pipeline.</returns> public static IPipeline Insert(this IPipelineCollection pipelines, int index, string name, params IModule[] modules) => pipelines.Insert(index, name, new ModuleList(modules));
/// <summary> /// Inserts a new unnamed pipeline into the collection. /// </summary> /// <param name="pipelines">The pipeline collection.</param> /// <param name="index">The index at which to insert the new pipeline.</param> /// <param name="modules">The modules the new pipeline should contain.</param> /// <returns>The newly inserted pipeline.</returns> public static IPipeline Insert(this IPipelineCollection pipelines, int index, IModuleList modules) => pipelines.Insert(index, null, modules);