Exemplo n.º 1
0
        private void AddPipelineComponent(IPipelineComponent toRealize, DataFlowComponentVisualisation.Role role)
        {
            Exception exConstruction;

            //create the pipeline realization (might fail
            var value = _pipelineFactory.TryCreateComponent(toRealize, out exConstruction);

            if (role != DataFlowComponentVisualisation.Role.Source)
            {
                AddDividerIfReorderingAvailable();
            }

            //create the visualization
            var component = new PipelineComponentVisualisation(toRealize, role, value, exConstruction, component_shouldAllowDrop);

            component.DragDrop += component_DragDrop;
            flpPipelineDiagram.Controls.Add(component);//add the component

            //try to initialize the realization (we do this after creating visualization so that when the events come in we can record where on UI the consumption events happen and also because later on it might be that initialization takes ages and we want to use a Thread)
            if (value != null)
            {
                try
                {
                    if (!_useCase.IsDesignTime)
                    {
                        _useCase.GetContext().PreInitializeGeneric(new ThrowImmediatelyDataLoadEventListener(), value, _useCase.GetInitializationObjects().ToArray());
                        component.Check();
                    }

                    component.CheckMandatoryProperties();
                }
                catch (Exception exInit)
                {
                    //initialization failed
                    component.ExInitialization = exInit;
                }
            }

            component.AllowDrag = AllowReOrdering;

            if (AllowSelection)
            {
                component.AllowSelection     = true;
                component.ComponentSelected += component_Selected;
            }


            //PipelineComponents can never be locked because they are user setup things
            component.IsLocked = false;
        }