Пример #1
0
 internal StateConfiguration(Dictionary <TState, StateRepresentation <TState, TTrigger> > representations,
                             TState currentState)
 {
     Representations            = representations;
     CurrentStateRepresentation = StateConfigurationHelper.FindOrCreateStateRepresentation(currentState,
                                                                                           representations);
 }
Пример #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);
        }