Beispiel #1
0
        private void MarkStatesViaChildren(NativeActivityMetadata metadata, Collection <State> states)
        {
            if (states.Count > 0)
            {
                for (int i = 0; i < states.Count; i++)
                {
                    State state = states[i];

                    if (string.IsNullOrEmpty(state.StateId))
                    {
                        state.StateId          = StateMachineIdHelper.GenerateStateId(RootId, i);
                        state.StateMachineName = this.DisplayName;
                    }
                    else
                    {
                        // the state has been makred already: a duplicate state is found
                        metadata.AddValidationError(new ValidationError(
                                                        SR.StateCannotBeAddedTwice(state.DisplayName),
                                                        isWarning: false,
                                                        propertyName: string.Empty,
                                                        sourceDetail: state));
                    }
                }
            }
        }
Beispiel #2
0
 private void OnStateComplete(NativeActivityContext context, ActivityInstance completedInstance, string result)
 {
     if (StateMachineIdHelper.IsAncestor(RootId, result))
     {
         int index = StateMachineIdHelper.GetChildStateIndex(RootId, result);
         context.ScheduleFunc <StateMachineEventManager, string>(
             _internalStateFuncs[index],
             _eventManager.Get(context),
             _onStateComplete);
     }
 }
Beispiel #3
0
        //protected override void OnCreateDynamicUpdateMap(NativeActivityUpdateMapMetadata metadata, Activity originalActivity)
        //{
        //    // enable dynamic update in state machine
        //    metadata.AllowUpdateInsideThisActivity();
        //}

        private static void MarkTransitionsInState(State state)
        {
            if (state.Transitions.Count > 0)
            {
                for (int i = 0; i < state.Transitions.Count; i++)
                {
                    Transition transition = state.Transitions[i];
                    if (!string.IsNullOrEmpty(state.StateId))
                    {
                        transition.Id = StateMachineIdHelper.GenerateTransitionId(state.StateId, i);
                    }
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Execution of StateMachine
        /// </summary>
        /// <param name="context">NativeActivityContext reference</param>
        //[SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0",
        //Justification = "The context is used by workflow runtime. The parameter should be fine.")]
        protected override void Execute(NativeActivityContext context)
        {
            // We view the duration before moving to initial state is on transition.
            StateMachineEventManager localEventManager = _eventManager.Get(context);

            localEventManager.OnTransition = true;
            localEventManager.CurrentBeingProcessedEvent = null;
            int index = StateMachineIdHelper.GetChildStateIndex(RootId, this.InitialState.StateId);

            context.ScheduleFunc <StateMachineEventManager, string>(
                _internalStateFuncs[index],
                localEventManager,
                _onStateComplete);
        }