private Task ExecuteNextNode([NotNull] IActivityNode node, [NotNull] Task task) { if (task.IsCanceled) { Log.Info("At node: {0}. Cancelled", node); IFlowNode handlerNode = node.CancellationHandler; Debug.Assert(handlerNode != null); return(handlerNode.Accept(this)); } if (task.IsFaulted) { string message = $"At node: {node}. Faulted"; Log.Exception(message, task.Exception); IFaultHandlerNode handlerNode = node.FaultHandler; Debug.Assert(handlerNode != null); return(handlerNode.Accept(this)); } Log.Info("At node: {0}. Completed", node); if (node.PointsTo != null) { return(node.PointsTo.Accept(this)); } return(TaskHelper.CompletedTask); }
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)); }
public Task VisitCondition(ConditionNode conditionNode) { conditionNode.AssertNotNull("conditionNode != null"); Log.Info("At node: {0}. Condition entered", conditionNode); bool condition = conditionNode.EvaluateCondition(); Log.Info("At node: {0}. Condition evaluated to: '{1}'", conditionNode, condition); IFlowNode branch = condition ? conditionNode.WhenTrue : conditionNode.WhenFalse; if (branch == null) { return(TaskHelper.CompletedTask); } return(branch.Accept(this)); }
public static IEnumerable <IFlowNode> GetNeighbors(this IFlowNode node) { return(node.Accept(Visitor)); }