void LoadComponent(Node node, DecisionTreeComponent component)
        {
            if (!node.Outputs.Any())
            {
                SetSelectedIndex(decisionTreeGraph.ActionIds);
                return;
            }

            SetSelectedIndex(decisionTreeGraph.DecisionIds);

            var decision = component as DecisionData;

            LoadComponentFromPort("Output1", decision.OnTrue);
            LoadComponentFromPort("Output2", decision.OnFalse);

            void SetSelectedIndex(int[] ids)
            {
                var selectedIndex = 0;

                for (int i = 0; i < ids.Length; i++)
                {
                    if (ids[i] != (int)component.Type)
                    {
                        continue;
                    }

                    selectedIndex = i;
                    break;
                }

                var selectable = node as ISelected;

                selectable.Selected = selectedIndex;
            }

            void LoadComponentFromPort(string name,
                                       DecisionTreeComponent decisionComponent)
            {
                var port           = node.GetPort(name);
                var connectionNode = SelectConnectionNode(port, component.Type);

                LoadComponent(connectionNode, decisionComponent);
            }
        }
Example #2
0
 public DecisionFactory(DecisionTreeCreatorVisitor decisionTreeCreatorVisitor,
                        DecisionTreeComponent component)
 {
     this.decisionTreeCreatorVisitor = decisionTreeCreatorVisitor;
     this.component = component;
 }