Beispiel #1
0
        internal static StateConfiguration <TState, TTrigger> Ignore <TState, TTrigger>(
            StateConfiguration <TState, TTrigger> config, Func <bool> predicate, TTrigger trigger)
        {
            Contract.NotNull(trigger != null, nameof(trigger));

            if (
                StateConfigurationHelper.FindTriggerRepresentation(trigger,
                                                                   config.CurrentStateRepresentation) != null)
            {
                ExceptionHelper.ThrowExclusiveOperation();
            }

            var rep = StateConfigurationHelper.CreateTriggerRepresentation(trigger,
                                                                           config.CurrentStateRepresentation);

            rep.NextStateRepresentationWrapper = null;
            rep.ConditionalTriggerPredicate    = predicate;

            return(config);
        }
Beispiel #2
0
        private static StateConfiguration <TState, TTrigger> PermitCore <TState, TTrigger>(
            StateConfiguration <TState, TTrigger> config, Func <bool> predicate, TTrigger trigger,
            TState resultingState, object onTriggerAction)
        {
            Contract.NotNull(trigger != null, nameof(trigger));
            Contract.NotNull(resultingState != null, nameof(resultingState));

            if (StateConfigurationHelper.FindTriggerRepresentation(trigger, config.CurrentStateRepresentation) !=
                null)
            {
                ExceptionHelper.ThrowExclusiveOperation();
            }

            var rep = StateConfigurationHelper.CreateTriggerRepresentation(trigger,
                                                                           config.CurrentStateRepresentation);

            rep.NextStateRepresentationWrapper = StateConfigurationHelper.FindOrCreateStateRepresentation(
                resultingState, config.Representations);
            rep.OnTriggerAction             = onTriggerAction;
            rep.ConditionalTriggerPredicate = predicate;

            return(config);
        }
Beispiel #3
0
        private static StateConfiguration <TState, TTrigger> PermitDynamicCore <TState, TTrigger>(
            StateConfiguration <TState, TTrigger> config, TTrigger trigger,
            object targetStatePredicate, object onTriggerAction)
        {
            Contract.NotNull(trigger != null, nameof(trigger));
            Contract.NotNull(targetStatePredicate != null, nameof(targetStatePredicate));

            if (
                StateConfigurationHelper.FindTriggerRepresentation(trigger,
                                                                   config.CurrentStateRepresentation) != null)
            {
                ExceptionHelper.ThrowExclusiveOperation();
            }

            var rep = StateConfigurationHelper.CreateTriggerRepresentation(trigger,
                                                                           config.CurrentStateRepresentation);

            rep.NextStateRepresentationWrapper = targetStatePredicate;
            rep.OnTriggerAction             = onTriggerAction;
            rep.ConditionalTriggerPredicate = null;
            rep.TransitionFlags            |= TransitionFlag.DynamicState;

            return(config);
        }