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); } }
protected override void VisitSwitch <TChoice>(SwitchNode <TChoice> switchNode) { AddReachable(switchNode.DefaultCase); foreach (KeyValuePair <TChoice, IFlowNode> choiceToNode in switchNode.Cases) { AddReachable(choiceToNode.Value); } }
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); } }
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) { }
internal CaseBinder([NotNull] SwitchNode <TChoice> switchNode, [NotNull] TChoice choice) { mySwitchNode = switchNode; myChoice = choice; }
protected abstract void VisitSwitch <TChoice>([NotNull] SwitchNode <TChoice> switchNode);
Null INodeVisitor <Null> .VisitSwitch <TChoice>(SwitchNode <TChoice> switchNode) { VisitSwitch(switchNode); return(null); }