AVM.DDP.MetaTBManifest.AddAllTasks C# (CSharp) Method

AddAllTasks() public method

public AddAllTasks ( ISIS.GME.Dsml.CyPhyML.Interfaces testBenchType, IEnumerable interpreters ) : void
testBenchType ISIS.GME.Dsml.CyPhyML.Interfaces
interpreters IEnumerable
return void
        public void AddAllTasks(
            CyPhy.TestBenchType testBenchType,
            IEnumerable<global::META.ComComponent> interpreters)
        {
            Contract.Requires(testBenchType != null);
            Contract.Requires(interpreters != null);

            var workflowRef = testBenchType.Children
                                           .WorkflowRefCollection
                                           .ToList();

            if (workflowRef.Count == 1 && workflowRef[0].AllReferred != null)
            {
                var workflow = workflowRef[0].Referred.Workflow;
                var allTasks = workflow.Children.TaskBaseCollection;

                var startTask = allTasks
                                .Where(x => x.AllSrcConnections.Count() == 0)
                                .FirstOrDefault();
                CyPhy.TaskBase nextTask = startTask;

                int regularTaskIndex = 0;
                int regularTaskCount = interpreters.Count();                
                var processed = new List<CyPhy.TaskBase>();

                while (nextTask != null &&
                        processed.Contains(nextTask) == false)
                {
                    processed.Add(nextTask);

                    if (nextTask.Impl.MetaBase.Name == (typeof(CyPhy.Task).Name))
                    {
                        if (regularTaskIndex < regularTaskCount)
                        {
                            var currTask = interpreters.ElementAt(regularTaskIndex++);
                            if (currTask.result != null &&
                                currTask.result.RunCommand != null)
                            {
                                var step = new Step();
                                step.Invocation = currTask.result.RunCommand;
                                this.Steps.Add(step);
                            }
                        }
                    }
                    else if (nextTask.Impl.MetaBase.Name == (typeof(CyPhy.ExecutionTask).Name))
                    {
                        CyPhy.ExecutionTask executionTask = ISIS.GME.Dsml.CyPhyML.Classes.ExecutionTask.Cast(nextTask.Impl);

                        var step = new Step();

                        step.Description = executionTask.Attributes.Description;
                        step.Invocation = executionTask.Attributes.Invocation;
                        step.PreProcess = executionTask.Attributes.PreProcess;
                        step.PostProcess = executionTask.Attributes.PostProcess;

                        var splitStrings = new string[]{Environment.NewLine, "\n"};
                        foreach (var parameterValue in executionTask.Attributes.Parameters.Split(splitStrings, StringSplitOptions.RemoveEmptyEntries))
                        {
                            Parameter parameter = new Parameter();
                            parameter.Name = parameterValue;
                            step.Parameters.Add(parameter);
                        }

                        this.Steps.Add(step);
                    }

                    var flow = nextTask.DstConnections.FlowCollection.FirstOrDefault();
                    if (flow == null)
                    {
                        nextTask = null;
                    }
                    else
                    {
                        nextTask = flow.DstEnds.TaskBase;
                    }
                }
            }
        }