Пример #1
0
            async Task ExecuteInternalActionsAsync(Transition transition, object[] args)
            {
                InternalTriggerBehaviour internalTransition = null;

                // Look for actions in superstate(s) recursivly until we hit the topmost superstate, or we actually find some trigger handlers.
                StateRepresentation aStateRep = this;

                while (aStateRep != null)
                {
                    if (aStateRep.TryFindLocalHandler(transition.Trigger, args, out TriggerBehaviourResult result))
                    {
                        // Trigger handler(s) found in this state
                        internalTransition = result.Handler as InternalTriggerBehaviour;
                        break;
                    }
                    // Try to look for trigger handlers in superstate (if it exists)
                    aStateRep = aStateRep._superstate;
                }

                // Execute internal transition event handler
                if (internalTransition == null)
                {
                    throw new ArgumentNullException("The configuration is incorrect, no action assigned to this internal transition.");
                }
                await(internalTransition.ExecuteAsync(transition, args)).ConfigureAwait(false);
            }
Пример #2
0
            internal void InternalAction(Transition transition, object[] args)
            {
                InternalTriggerBehaviour.Sync internalTransition = null;

                // Look for actions in superstate(s) recursivly until we hit the topmost superstate, or we actually find some trigger handlers.
                StateRepresentation aStateRep = this;

                while (aStateRep != null)
                {
                    if (aStateRep.TryFindLocalHandler(transition.Trigger, args, out TriggerBehaviourResult result))
                    {
                        // Trigger handler found in this state
                        if (result.Handler is InternalTriggerBehaviour.Async)
                        {
                            throw new InvalidOperationException("Running Async internal actions in synchronous mode is not allowed");
                        }

                        internalTransition = result.Handler as InternalTriggerBehaviour.Sync;
                        break;
                    }
                    // Try to look for trigger handlers in superstate (if it exists)
                    aStateRep = aStateRep._superstate;
                }

                // Execute internal transition event handler
                if (internalTransition == null)
                {
                    throw new ArgumentNullException("The configuration is incorrect, no action assigned to this internal transition.");
                }
                internalTransition.InternalAction(transition, args);
            }
Пример #3
0
            internal void InternalAction(Transition transition, object[] args)
            {
                var possibleActions = new List <InternalActionBehaviour>();

                // Look for actions in superstate(s) recursivly until we hit the topmost superstate, or we actually find some trigger handlers.
                StateRepresentation aStateRep = this;

                while (aStateRep != null)
                {
                    if (aStateRep.TryFindLocalHandler(transition.Trigger, out TriggerBehaviourResult result))
                    {
                        // Trigger handler(s) found in this state
                        possibleActions.AddRange(aStateRep._internalActions);
                        break;
                    }
                    // Try to look for trigger handlers in superstate (if it exists)
                    aStateRep = aStateRep._superstate;
                }

                // Execute internal transition event handler
                foreach (var action in possibleActions)
                {
                    action.Execute(transition, args);
                }
            }