Exemple #1
0
        private GraphNode GetGraphNode(IFlowNode node)
        {
            GraphNode graphNode;

            nodeList.TryGetValue(node.GetID(), out graphNode);
            return(graphNode);
        }
Exemple #2
0
        public static string ToCategory([NotNull] this IFlowNode node)
        {
            if (node is IFaultHandlerNode)
            {
                return(Categories.FaultHandlerNode);
            }

            switch (node.Kind)
            {
            case FlowNodeKind.Activity:
                return(Categories.ActivityNode);

            case FlowNodeKind.Condition:
                return(Categories.ConditionNode);

            case FlowNodeKind.Switch:
                return(Categories.SwitchNode);

            case FlowNodeKind.ForkJoin:
                return(Categories.ForkJoinNode);

            case FlowNodeKind.Block:
                return(Categories.BlockNode);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemple #3
0
 private void AddReachable(IFlowNode node)
 {
     if (node != null)
     {
         myReachableNodes.Add(node);
     }
 }
 public FlowNodeStatusChangedEventArgs(IFlowNode node, FlowNodeStatus newStatus, MessageHeader header, IMessageBody body)
 {
     Node      = node ?? throw new ArgumentNullException(nameof(node));
     NewStatus = newStatus;
     Header    = header;
     Body      = body;
 }
Exemple #5
0
 public UnslicedNode(IFlowNode node, float width, float height, WrapMode forceWrap)
 {
     Node      = node;
     Width     = width;
     Height    = height;
     ForceWrap = forceWrap;
 }
Exemple #6
0
 private void CheckSelfReference(IFlowNode from, IFlowNode to)
 {
     if (ReferenceEquals(from, to))
     {
         Result.AddError(from, "Node points to itself");
     }
 }
Exemple #7
0
        public void AddError([NotNull] IFlowNode node, [NotNull] string errorMessage)
        {
            node.AssertNotNull("node != null");
            errorMessage.AssertNotNullOrEmpty("Error message cannot be null or empty");

            myErrors.Add(new ValidationError(node, errorMessage));
        }
        private void CheckActivityType([NotNull] Type activityType, [NotNull] IFlowNode node)
        {
#if PORTABLE
            var typeInfo = activityType.GetTypeInfo();
#else
            var typeInfo = activityType;
#endif
            if (typeInfo.IsAbstract)
            {
                Result.AddError(node, $"Activity {activityType.Name} is abstract and cannot be instanciated");
                return;
            }

            if (typeInfo.IsGenericTypeDefinition)
            {
                Result.AddError(node, $"Activity {activityType.Name} is generic type definition and cannot be instanciated");
                return;
            }
#if PORTABLE
            if (!typeInfo.DeclaredConstructors.Any(c => !c.IsStatic && c.IsPublic))
            {
                Result.AddError(node, $"Activity {activityType.Name} has no public constructors");
            }
#else
            if (typeInfo.GetConstructors(BindingFlags.Public | BindingFlags.Instance).Length == 0)
            {
                Result.AddError(node, $"Activity {activityType.Name} has no public constructors");
            }
#endif
        }
        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);
        }
Exemple #10
0
        public void CheckFlowWithBlock()
        {
            // Arrange
            var b = new FlowBuilder();

            IFlowNode a = null;
            IFlowNode e = null;

            var block = b.Block("test", (_, builder) =>
            {
                a = builder.DummyActivity();
                e = builder.DummyActivity();
            });

            b.WithInitialNode(block);

            var validator = new ReachabilityValidator();

            // Act
            validator.Validate(b.CreateFlow());
            var result = validator.Result;

            // Assert
            Assert.That(result.GetErrorsOf(block), Is.Empty);
            Assert.That(result.GetErrorsOf(a), Is.Empty);
            Assert.That(result.GetErrorsOf(e), Is.Not.Empty);
        }
Exemple #11
0
        void CreateSMAction(IFlow flow, IFlowNode from, IFlowNode to, int beginIndex, int endIndex)
        {
            var fa = flow.CreateAction(from, to) as StateMachine.CIIPXpoTransition;

            fa.BeginItemPointIndex = beginIndex;
            fa.EndItemPointIndex   = endIndex;
        }
 private void AddLink(
     [NotNull] IFlowNode from,
     [CanBeNull] IFlowNode to,
     [CanBeNull] string category = null, [CanBeNull] string label = null)
 {
     AddLink(from.Id, to?.Id, category, label);
 }
Exemple #13
0
        void CreateAction(IFlow flow, IFlowNode from, IFlowNode to, int beginIndex, int endIndex)
        {
            var fa = flow.CreateAction(from, to) as FlowAction;

            fa.Created();
            fa.BeginItemPointIndex = beginIndex;
            fa.EndItemPointIndex   = endIndex;
        }
Exemple #14
0
        public ValidationError([NotNull] IFlowNode node, [NotNull] string message)
        {
            node.AssertNotNull("node != null");

            NodeId   = node.Id;
            NodeName = node.Name;
            Message  = message.NotNull();
        }
Exemple #15
0
        public SwitchNode <TChoice> ConnectDefaultTo([NotNull] IFlowNode node)
        {
            node.AssertNotNull("node != null");
            DefaultCase.AssertIsNull("Default case is already set");

            DefaultCase = node;
            return(this);
        }
Exemple #16
0
        public IFlowNode Select([NotNull] TChoice choice)
        {
            IFlowNode node = FindCaseHandler(choice) ?? DefaultCase;

            node.AssertNotNull("No such case handler");

            return(node);
        }
Exemple #17
0
        public override void RemoveConnections()
        {
            DefaultCase = null;
            myCases.Clear();

            Choice           = null;
            myCompiledChoice = null;
        }
Exemple #18
0
            public SwitchNode <TChoice> To([NotNull] IFlowNode node)
            {
                node.AssertNotNull("node != null");

                mySwitchNode.AddCase(myChoice, node);

                return(mySwitchNode);
            }
Exemple #19
0
        public BlockNode AddNode([NotNull] IFlowNode node)
        {
            node.AssertNotNull("node != null");
            node.AssertIsNotItemOf(myNodes, "Node is already in the block");

            myNodes.Add(node);
            return(this);
        }
Exemple #20
0
        public ConditionNode ConnectFalseTo([NotNull] IFlowNode node)
        {
            node.AssertNotNull("node != null");
            WhenFalse.AssertIsNull("False branch is already set");

            WhenFalse = node;
            return(this);
        }
Exemple #21
0
        public override void RemoveConnections()
        {
            WhenFalse = null;
            WhenTrue  = null;

            Condition           = null;
            myCompiledCondition = null;
        }
Exemple #22
0
        protected internal virtual void ConnectTarget(IFlowNode target)
        {
            CurrentSequenceFlowBuilder.From(element).To(target);

            ISequenceFlow sequenceFlow = CurrentSequenceFlowBuilder.element;

            CreateBpmnEdge(sequenceFlow);
            _currentSequenceFlowBuilder = null;
        }
Exemple #23
0
        IFlowAction IFlow.CreateAction(IFlowNode from, IFlowNode to)
        {
            var obj = new CIIPXpoTransition(Session);

            obj.SourceState = from as CIIPXpoState;
            obj.TargetState = to as CIIPXpoState;
            obj.Caption     = obj.TargetState.Caption;
            return(obj);
        }
        public static TNode ConnectTo <TNode>([NotNull] this TNode from, [NotNull] IFlowNode to)
            where TNode : ConnectableNode
        {
            from.AssertNotNull("from != null");
            to.AssertNotNull("to != null");
            from.PointsTo.AssertIsNull("Connection is already set");

            from.PointsTo = to;
            return(from);
        }
Exemple #25
0
 public FlowNodePanel(string txt, int num, IFlowNode nodeControl, int LeftOrRight = 0, FlowNodeStatu statu = FlowNodeStatu.Default)
 {
     this._text                    = txt;
     this._step                    = num;
     this._leftOrRight             = LeftOrRight;
     this._nodeControl             = nodeControl;
     this._nodeControl.OnFinished += new EventHandler(_nodeControl_OnFinished);
     this.init();
     this.SetStatu(statu, this._rightFinished);
 }
        public BlockSelfContainednessValidator(
            [NotNull] BlockNode block,
            [CanBeNull] IFlowNode defaultFaultHandler, [CanBeNull] IFlowNode defaultCancellationHandler)
        {
            myBlock = block.NotNull();
            myDefaultFaultHandler        = defaultFaultHandler;
            myDefaultCancellationHandler = defaultCancellationHandler;

            Result = new ValidationResult();
        }
        public FlowBuilder WithInitialNode([NotNull] IFlowNode node)
        {
            node.AssertNotNull("node != null");
            myInitialNode.AssertIsNull("Initial node is already specified");
            node.AssertIsItemOf(myNodes, "Node must be part of the flow");
            myIsFreezed.AssertFalse("Builder is freezed");

            myInitialNode = node;
            return(this);
        }
Exemple #28
0
        IFlowAction IFlow.CreateAction(IFlowNode from, IFlowNode to)
        {
            var act = new FlowAction(Session)
            {
                From = (FlowNode)from, To = (FlowNode)to, Caption = "生成" + to.Caption
            };

            act.Flow = this;
            act.GenerateMapping(CaptionHelper.ApplicationModel.BOModel);
            return(act);
        }
        private void CheckIfNodeIsInsideBlock(IFlowNode node)
        {
            if (node == null || node == myDefaultFaultHandler || node == myDefaultCancellationHandler)
            {
                return;
            }

            if (myBlock.InnerNodes.IndexOf(node) == -1)
            {
                Result.AddError(node, "Node is out of block " + myBlock);
            }
        }
Exemple #30
0
 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;
 }
Exemple #31
0
 public void RemoveNode(IFlowNode node)
 {
     Nodes.Remove((NavigationMenuItem) node);
 }
Exemple #32
0
 public void RemoveNode(IFlowNode node)
 {
 }
Exemple #33
0
 public IFlowAction CreateAction(IFlowNode from, IFlowNode to)
 {
     return null;
 }
Exemple #34
0
 IFlowAction IFlow.CreateAction(IFlowNode from, IFlowNode to)
 {
     var act = new NavigationLine(Session)
     {
         From = (NavigationMenuItem) from,
         To = (NavigationMenuItem) to,
         //Caption = "����" + to.Caption
     };
     this.Actions.Add(act);
     return act;
 }
Exemple #35
0
 void IFlow.RemoveNode(IFlowNode node)
 {
     Nodes.Remove((FlowNode)node);
 }
Exemple #36
0
 IFlowAction IFlow.CreateAction(IFlowNode from, IFlowNode to)
 {
     var act =  new FlowAction(Session) {From = (FlowNode) from, To = (FlowNode) to, Caption = "生成" + to.Caption};
     act.Flow = this;
     act.Created();
     //act.GenerateMapping(CaptionHelper.ApplicationModel.BOModel);
     return act;
 }
        IFlowAction IFlow.CreateAction(IFlowNode from, IFlowNode to)
        {
            var obj = new CIIPXpoTransition(Session);

            obj.SourceState = from as CIIPXpoState;
            obj.TargetState = to as CIIPXpoState;
            obj.Caption = obj.TargetState.Caption;
            return obj;
        }
 void IFlow.RemoveNode(IFlowNode node)
 {
     States.Remove((CIIPXpoState)node);
 }