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); }
/// <summary> /// Registers a child activity node. /// </summary> /// <param name="Node">Activity node.</param> public void Register(IActivityNode Node) { if (this.activityNodes is null) { this.activityNodes = new LinkedList <IActivityNode>(); } this.Model.Register(this.activityNodes.AddLast(Node)); }
public static TActivityNode ConnectCancellationTo <TActivityNode>( [NotNull] this TActivityNode from, [NotNull] IActivityNode to) where TActivityNode : ActivityNode { from.AssertNotNull("from != null"); to.AssertNotNull("to != null"); from.CancellationHandler.AssertIsNull("Cancellation handler is already set"); from.CancellationHandler = to; return(from); }
public FlowBuilder WithDefaultCancellationHandler <TCancellationHandler>( [NotNull] ActivityNode <TCancellationHandler> handler) where TCancellationHandler : class, IActivity { handler.AssertNotNull("handler != null"); myDefaultCancellationHandler.AssertIsNull("Default cancellation handler is already set"); handler.AssertIsItemOf(myNodes, "Handler must be part of the flow"); myIsFreezed.AssertFalse("Builder is freezed"); myDefaultCancellationHandler = handler; return(this); }
internal FlowDescription( [CanBeNull] IFlowNode initialNode, [CanBeNull] IFaultHandlerNode defaultFaultHandler, [CanBeNull] IActivityNode defaultCancellationHandler, [NotNull] ReadOnlyCollection <IFlowNode> nodes, [NotNull] ReadOnlyCollection <IVariable> globalVariables) { InitialNode = initialNode; DefaultFaultHandler = defaultFaultHandler; DefaultCancellationHandler = defaultCancellationHandler; Nodes = nodes; GlobalVariables = globalVariables; }
public void Clear() { myDefaultCancellationHandler = null; myDefaultFaultHandler = null; foreach (IFlowNode node in myNodes) { node.RemoveConnections(); } myNodes.Clear(); myGlobalVariables.Clear(); }
private void CheckActivityNode(IActivityNode node) { CheckSelfReference(node, node.PointsTo); CheckSelfReference(node, node.FaultHandler); CheckSelfReference(node, node.CancellationHandler); if (node.FaultHandler == null && Flow.DefaultFaultHandler == null) { Result.AddError(node, "Neither node nor the flow has a fault handler"); } if (node.CancellationHandler == null && Flow.DefaultCancellationHandler == null) { Result.AddError(node, "Neither node nor the flow has a cancellation handler"); } }
public void ToExceptionOf([NotNull] IActivityNode activity) { activity.AssertNotNull("activity != null"); var bindingInfo = new FaultBinding(myPropertyName, activity); myActivityDescriptor.AddBindingInfo(bindingInfo); ActivityTaskHandler handler = task => { if (task.Status == TaskStatus.Faulted) { myActivityDescriptor.AddInitializer(a => SetProperty(a, task.Exception)); } }; activity.RegisterActivityTaskHandler(handler); }
public void SubscribeToExceptionsOf(IActivityNode node) { node.AssertNotNull("node != null"); Bind(x => x.Exception).ToExceptionOf(node); }
public DefaultHandlersSetter([NotNull] FlowDescription flowDescription) { myFlowDescription = flowDescription.NotNull(); myFaultHandler = flowDescription.DefaultFaultHandler; myCancellationHandler = flowDescription.DefaultCancellationHandler; }
public FaultBinding(string propertyName, IActivityNode node) { PropertyName = propertyName.NotNullOrEmpty("propertyName"); Node = node.NotNull(); }
private void VisitActivityNode(IActivityNode node) { AddReachable(node.PointsTo); AddReachable(node.FaultHandler); AddReachable(node.CancellationHandler); }