public static void AddIfNonExisting(this IPipelineCollection pipelineCollection, IPipeline pipeline) { string name = (pipeline as INamedPipeline)?.PipelineName ?? pipeline?.GetType().Name; if (!pipelineCollection.ContainsKey(name)) { pipelineCollection.Add(name, 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)); }
private PipelinePhase GetPipelineAndPhase( string pipelineName, Phase phase, IPipelineCollection pipelines, ConcurrentDictionary <string, ImmutableArray <IDocument> > documentCollection, IDocument[] documents, params PipelinePhase[] dependencies) { TestPipeline pipeline = new TestPipeline(); PipelinePhase pipelinePhase = new PipelinePhase(pipeline, pipelineName, phase, Array.Empty <IModule>(), NullLogger.Instance, dependencies); pipelines.Add(pipelineName, pipeline); documentCollection.AddOrUpdate(pipelineName, documents.ToImmutableArray(), (_, __) => documents.ToImmutableArray()); return(pipelinePhase); }
private PipelinePhase GetPipelineAndPhase( string pipelineName, Phase phase, IPipelineCollection pipelines, ConcurrentDictionary <string, PhaseResult[]> phaseResults, IDocument[] outputs, params PipelinePhase[] dependencies) { TestPipeline pipeline = new TestPipeline(); PipelinePhase pipelinePhase = new PipelinePhase(pipeline, pipelineName, phase, Array.Empty <IModule>(), NullLogger.Instance, dependencies); pipelines.Add(pipelineName, pipeline); PhaseResult[] results = new PhaseResult[4]; results[(int)Phase.Process] = new PhaseResult(pipelineName, Phase.Process, outputs.ToImmutableArray(), 0); phaseResults.TryAdd(pipelineName, results); return(pipelinePhase); }
private PipelinePhase GetPipelineAndPhase( string pipelineName, Phase currentPhase, IPipelineCollection pipelines, ConcurrentDictionary <string, PhaseResult[]> phaseResults, IDocument[] outputs, Phase phaseForOutputs, params PipelinePhase[] dependencies) { TestPipeline pipeline = new TestPipeline(); PipelinePhase pipelinePhase = new PipelinePhase(pipeline, pipelineName, currentPhase, Array.Empty <IModule>(), NullLogger.Instance, dependencies); pipelines.Add(pipelineName, pipeline); PhaseResult[] results = new PhaseResult[4]; if (outputs != null) { results[(int)phaseForOutputs] = new PhaseResult(pipelineName, phaseForOutputs, outputs.ToImmutableArray(), default, 0);
/// <summary> /// Adds a new named pipeline to the collection. /// </summary> /// <param name="pipelines">The pipeline collection.</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 added pipeline.</returns> public static IPipeline Add(this IPipelineCollection pipelines, string name, params IModule[] modules) => pipelines.Add(name, new ModuleList(modules));
/// <summary> /// Adds a new unnamed pipeline to the collection. /// </summary> /// <param name="pipelines">The pipeline collection.</param> /// <param name="modules">The modules the new pipeline should contain.</param> /// <returns>The newly added pipeline.</returns> public static IPipeline Add(this IPipelineCollection pipelines, IModuleList modules) => pipelines.Add(null, modules);
public static void Add(this IPipelineCollection pipelineCollection, IPipeline pipeline) => pipelineCollection.Add((pipeline as INamedPipeline)?.PipelineName ?? pipeline?.GetType().Name, pipeline);