public void SetTo(IPipeline pipeline, IPipelineUseCase useCase) { _useCase = useCase; _pipeline = pipeline; if (_pipeline != null) { _pipeline.ClearAllInjections(); } //clear the diagram flpPipelineDiagram.Controls.Clear(); pipelineSmiley.Reset(); try { //if there is a pipeline if (_pipeline != null) { try { _pipelineFactory = new DataFlowPipelineEngineFactory(_useCase, _pipeline); //create it IDataFlowPipelineEngine pipelineInstance = _pipelineFactory.Create(pipeline, new ThrowImmediatelyDataLoadEventListener()); //initialize it (unless it is design time) if (!_useCase.IsDesignTime) { pipelineInstance.Initialize(_useCase.GetInitializationObjects().ToArray()); } } catch (Exception ex) { pipelineSmiley.Fatal(ex); } //There is a pipeline set but we might have been unable to fully realize it so setup stuff based on PipelineComponents //was there an explicit instance? if (_useCase.ExplicitSource != null) { AddExplicit(_useCase.ExplicitSource);//if so add it } else //there wasn't an explicit one so there was a PipelineComponent maybe? albiet one that might be broken? if (pipeline.SourcePipelineComponent_ID != null) { AddPipelineComponent((int)pipeline.SourcePipelineComponent_ID, DataFlowComponentVisualisation.Role.Source, pipeline.Repository); //add the possibly broken PipelineComponent to the diagram } else { AddBlankComponent(DataFlowComponentVisualisation.Role.Source); //the user hasn't put one in yet } foreach (var middleComponent in pipeline.PipelineComponents.Where(c => c.ID != pipeline.SourcePipelineComponent_ID && c.ID != pipeline.DestinationPipelineComponent_ID).OrderBy(comp => comp.Order)) { AddPipelineComponent(middleComponent, DataFlowComponentVisualisation.Role.Middle);//add the possibly broken PipelineComponent to the diagram } //was there an explicit instance? if (_useCase.ExplicitDestination != null) { AddDividerIfReorderingAvailable(); AddExplicit(_useCase.ExplicitDestination);//if so add it } else //there wasn't an explicit one so there was a PipelineComponent maybe? albiet one that might be broken? if (pipeline.DestinationPipelineComponent_ID != null) { AddPipelineComponent((int)pipeline.DestinationPipelineComponent_ID, DataFlowComponentVisualisation.Role.Destination, pipeline.Repository); //add the possibly broken PipelineComponent to the diagram } else { AddDividerIfReorderingAvailable(); AddBlankComponent(DataFlowComponentVisualisation.Role.Destination); //the user hasn't put one in yet } return; } //Fallback //user has not picked a pipeline yet, show him the shell (factory) //factory has no source, add empty source if (_useCase.ExplicitSource == null) { AddBlankComponent(DataFlowComponentVisualisation.Role.Source); } else { AddExplicit(_useCase.ExplicitSource); } //factory has no source, add empty source if (_useCase.ExplicitDestination == null) { AddBlankComponent(DataFlowComponentVisualisation.Role.Destination); } else { AddExplicit(_useCase.ExplicitDestination); } } finally { Invalidate(); } }