Exemplo n.º 1
0
        protected override void VisitSwitch <TChoice>(SwitchNode <TChoice> switchNode)
        {
            if (switchNode.Choice == null)
            {
                Result.AddError(switchNode, "Choice expression isn't set");
            }

            if (!switchNode.Cases.Any() && switchNode.DefaultCase == null)
            {
                Result.AddError(switchNode, "Switch contains no cases");
            }

            CheckSelfReference(switchNode, switchNode.DefaultCase);

            var  choices       = new List <TChoice>();
            bool hasDuplicates = false;

            foreach (KeyValuePair <TChoice, IFlowNode> choiceToNode in switchNode.Cases)
            {
                CheckSelfReference(switchNode, choiceToNode.Value);

                if (choices.Contains(choiceToNode.Key))
                {
                    hasDuplicates = true;
                }

                choices.Add(choiceToNode.Key);
            }

            if (hasDuplicates)
            {
                Result.AddError(switchNode, "Switch has duplicate cases");
            }
        }
        protected override void VisitSwitch <TChoice>(SwitchNode <TChoice> switchNode)
        {
            CheckIfNodeIsInsideBlock(switchNode.DefaultCase);

            foreach (KeyValuePair <TChoice, IFlowNode> pair in switchNode.Cases)
            {
                CheckIfNodeIsInsideBlock(pair.Value);
            }
        }
Exemplo n.º 3
0
        protected override void VisitSwitch <TChoice>(SwitchNode <TChoice> switchNode)
        {
            AddReachable(switchNode.DefaultCase);

            foreach (KeyValuePair <TChoice, IFlowNode> choiceToNode in switchNode.Cases)
            {
                AddReachable(choiceToNode.Value);
            }
        }
Exemplo n.º 4
0
 public IEnumerable <IFlowNode> VisitSwitch <TChoice>(SwitchNode <TChoice> switchNode)
 {
     if (switchNode.DefaultCase != null)
     {
         yield return(switchNode.DefaultCase);
     }
     foreach (KeyValuePair <TChoice, IFlowNode> caseToNode in switchNode.Cases)
     {
         yield return(caseToNode.Value);
     }
 }
Exemplo n.º 5
0
        public Task VisitSwitch <TChoice>(SwitchNode <TChoice> switchNode)
        {
            switchNode.AssertNotNull("switchNode != null");

            Log.Info("At node: {0}. Switch entered", switchNode);

            TChoice choice = switchNode.EvaluateChoice();

            Log.Info("At node: {0}. Switch choice evaluated to: '{1}'", switchNode, choice);

            IFlowNode branch = switchNode.Select(choice);

            return(branch.Accept(this));
        }
 protected override void VisitSwitch <TChoice>(SwitchNode <TChoice> switchNode)
 {
 }
Exemplo n.º 7
0
 internal CaseBinder([NotNull] SwitchNode <TChoice> switchNode, [NotNull] TChoice choice)
 {
     mySwitchNode = switchNode;
     myChoice     = choice;
 }
Exemplo n.º 8
0
 protected abstract void VisitSwitch <TChoice>([NotNull] SwitchNode <TChoice> switchNode);
Exemplo n.º 9
0
 Null INodeVisitor <Null> .VisitSwitch <TChoice>(SwitchNode <TChoice> switchNode)
 {
     VisitSwitch(switchNode);
     return(null);
 }