internal static AwaitableStateConfiguration <TState, TTrigger> Permit <TState, TTrigger>(
            AwaitableStateConfiguration <TState, TTrigger> config, object predicate, TTrigger trigger,
            TState resultingState, object onTriggerAction, AwaitableTransitionFlag flags)
        {
            Contract.NotNull(trigger != null, nameof(trigger));
            Contract.NotNull(resultingState != null, nameof(resultingState));

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

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

            rep.NextStateRepresentationWrapper =
                AwaitableStateConfigurationHelper.FindOrCreateStateRepresentation(resultingState,
                                                                                  config.Representations);
            rep.OnTriggerAction             = onTriggerAction;
            rep.ConditionalTriggerPredicate = predicate;
            rep.AwaitableTransitionFlags   |= flags;

            return(config);
        }
Example #2
0
 internal AwaitableStateConfiguration(
     Dictionary <TState, AwaitableStateRepresentation <TState, TTrigger> > representations,
     TState currentState)
 {
     Representations            = representations;
     CurrentStateRepresentation = AwaitableStateConfigurationHelper.FindOrCreateStateRepresentation(
         currentState, representations);
 }