Example #1
0
        private static ComputedNode CreateNodes(EvaluationContext context)
        {
            ComputedNode root = null;

            List <ComputedNode> computedNodes = new List <ComputedNode>();

            foreach (Step step in context.Steps)
            {
                ComputedNode cn = new ComputedNode()
                {
                    Results             = step.OutVariables.Select(i => context.GetValue(i)).ToArray(),
                    ExpressionImage     = step.Image,
                    Description         = step.SourceExpression.Title,
                    ResultVariableNames = step.OutVariables.ToList(),
                    Step = step
                };


                List <Branch> branches = new List <Branch>();

                foreach (SourceVariable variable in step.InSourceVariables)
                {
                    branches.Add(new Branch()
                    {
                        Node = new VariableNode()
                        {
                            Description = variable.Description,
                            Text        = DecoratedText.Create(variable.Name),
                            Name        = variable.Name,
                            Value       = context.GetValue(variable.Name)
                        }
                    });
                }

                /*
                 * foreach (string variable in step.InTempVariables)
                 * {
                 *  branches.Add(new Branch() { Node = computedNodes.First(j => j.ResultVariableNames.Contains(variable)) });
                 * }
                 */


                foreach (Step fromStep in step.Froms)
                {
                    branches.Add(new Branch()
                    {
                        Node = computedNodes.First(j => j.Step == fromStep)
                    });
                }


                List <Branch> distinctBranches = new List <Branch>();

                foreach (Branch branch in branches)
                {
                    if (!distinctBranches.Any(i => i.Node == branch.Node))
                    {
                        distinctBranches.Add(branch);
                        cn.InheritVariables(branch.Node);
                    }
                }

                cn.Branches = distinctBranches.ToList();


                computedNodes.Insert(0, cn);
                root = cn;
            }

            return(root);
        }
Example #2
0
 public TextExpression(string text, bool isItalic)
 {
     this.text     = DecoratedText.Create(text);
     this.isItalic = isItalic;
 }