Esempio n. 1
0
        /// <summary>
        /// Refreshes the state depending on the state of the predecessors and
        /// successors, using the associated <see cref="StateComposer"/>.
        /// </summary>
        /// <devdoc>
        /// We save this calculation of the node state in the current graph location
        /// (WRT predecessors) as an optimization for the PropertyChanged event.
        /// We want to prevent a case where an already blocked node (i.e. a join)
        /// raises the changed event when one of its predecessors changes to Blocked.
        /// In this case, the predecessor would have changed its state, but the
        /// join itself would not, as it was already blocked. This optimization
        /// would benefit the entire tree spanning from that join, potentially
        /// reducing quite importantly the refresh rates of the graph UI.
        /// This is important for all kinds of nodes, and is virtual because
        /// different ones have different calculation of their state WRT
        /// to the predecessors.
        /// </devdoc>
        protected virtual void ComposeState(StateChangeSource changeSource)
        {
            var calculatedState = this.StateComposer.ComposeState(this, changeSource);

            if (this.State != calculatedState)
            {
                this.State = calculatedState;
                this.OnStateChanged();
            }
        }
Esempio n. 2
0
            public NodeState ComposeState(INode node, StateChangeSource changeSource)
            {
                var final = node.Successors.Traverse <INode>(s => s.Successors).OfType <IFinal>().FirstOrDefault();

                if (final == null)
                {
                    return(node.State);
                }

                return(final.State == NodeState.Completed ? NodeState.Completed : NodeState.Enabled);
            }
Esempio n. 3
0
            public NodeState ComposeState(INode node, StateChangeSource changeSource)
            {
#if ImplicitPredecessorsCompleteCondition
                if (changeSource == StateChangeSource.Predecessor && node.Predecessors.Any())
                {
                    return(node.Predecessors.All(n => n.State == NodeState.Completed) ? NodeState.Unknown : NodeState.Blocked);
                }
#endif
                // Ignores successor changes.
                return(node.State);
            }
        public NodeState ComposeState(INode node, StateChangeSource changeSource)
        {
            Guard.NotNull(() => node, node);

#if ImplicitPredecessorsCompleteCondition
            if (changeSource == StateChangeSource.Predecessor && node.Predecessors.Any())
            {
                return node.Predecessors.All(n => n.State == NodeState.Completed) ? NodeState.Completed : NodeState.Blocked;
            }
#endif
            // Ignores successor changes.
            return node.State;
        }
Esempio n. 5
0
        /// <summary>
        /// Refreshes the state depending on the state of the predecessors and successors.
        /// </summary>
        protected override void ComposeState(StateChangeSource changeSource)
        {
            var state = this.StateComposer.ComposeState(this, changeSource);

            if (this.State != state)
            {
                var previouslyHadPredecessorBlocking = this.hasBlockingPredecessor;
                this.hasBlockingPredecessor = state == NodeState.Blocked;

                if (base.State != NodeState.Blocked && (this.hasBlockingPredecessor || previouslyHadPredecessorBlocking))
                {
                    this.OnStateChanged();
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Refreshes the state depending on the state of the predecessors and successors.
        /// </summary>
        protected override void ComposeState(StateChangeSource changeSource)
        {
            var state = this.StateComposer.ComposeState(this, changeSource);
            if (this.State != state)
            {
                var previouslyHadPredecessorBlocking = this.hasBlockingPredecessor;
                this.hasBlockingPredecessor = state == NodeState.Blocked;

                if (base.State != NodeState.Blocked && (this.hasBlockingPredecessor || previouslyHadPredecessorBlocking))
                {
                    this.OnStateChanged();
                }
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Refreshes the state depending on the state of the predecessors and 
 /// successors, using the associated <see cref="StateComposer"/>.
 /// </summary>
 /// <devdoc>
 /// We save this calculation of the node state in the current graph location 
 /// (WRT predecessors) as an optimization for the PropertyChanged event. 
 /// We want to prevent a case where an already blocked node (i.e. a join) 
 /// raises the changed event when one of its predecessors changes to Blocked. 
 /// In this case, the predecessor would have changed its state, but the 
 /// join itself would not, as it was already blocked. This optimization 
 /// would benefit the entire tree spanning from that join, potentially 
 /// reducing quite importantly the refresh rates of the graph UI. 
 /// This is important for all kinds of nodes, and is virtual because 
 /// different ones have different calculation of their state WRT 
 /// to the predecessors.
 /// </devdoc>
 protected virtual void ComposeState(StateChangeSource changeSource)
 {
     var calculatedState = this.StateComposer.ComposeState(this, changeSource);
     if (this.State != calculatedState)
     {
         this.State = calculatedState;
         this.OnStateChanged();
     }
 }
Esempio n. 8
0
 public NodeState ComposeState(INode node, StateChangeSource changeSource)
 {
     return(node.Successors.Any() && node.Predecessors.Any() ? NodeState.Completed : NodeState.Unknown);
 }
Esempio n. 9
0
 public NodeState ComposeState(INode node, StateChangeSource changeSource)
 {
     return node.Successors.Any() && node.Predecessors.Any() ? NodeState.Completed : NodeState.Unknown;
 }
Esempio n. 10
0
            public NodeState ComposeState(INode node, StateChangeSource changeSource)
            {
                var final = node.Successors.Traverse<INode>(s => s.Successors).OfType<IFinal>().FirstOrDefault();
                if (final == null)
                    return node.State;

                return final.State == NodeState.Completed ? NodeState.Completed : NodeState.Enabled;
            }