Example #1
0
        /// <summary>
        /// When leaving the specified state
        /// </summary>
        /// <param name="state"></param>
        /// <param name="activityCallback"></param>
        /// <returns></returns>
        protected void WhenLeave(State state, Func <EventActivityBinder <TInstance>, EventActivityBinder <TInstance> > activityCallback)
        {
            State <TInstance> activityState = GetState(state.Name);

            EventActivityBinder <TInstance> binder = new TriggerEventActivityBinder <TInstance>(this, activityState.Leave);

            binder = activityCallback(binder);

            During(state, binder);
        }
Example #2
0
        void BindEveryTransitionEvent(Func <EventActivityBinder <TInstance>, EventActivityBinder <TInstance> > activityCallback,
                                      Func <State <TInstance>, Event> eventProvider)
        {
            State <TInstance>[] states = _stateCache.Values.ToArray();

            ActivityBinder <TInstance>[] binders = states.Select(state =>
            {
                EventActivityBinder <TInstance> binder = new TriggerEventActivityBinder <TInstance>(this, eventProvider(state));

                return(activityCallback(binder));
            }).SelectMany(x => x.GetStateActivityBinders()).ToArray();

            foreach (var state in states)
            {
                foreach (var binder in binders)
                {
                    binder.Bind(state);
                }
            }
        }