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);
        }
        internal static AwaitableStateConfiguration <TState, TTrigger> Ignore <TState, TTrigger>(
            AwaitableStateConfiguration <TState, TTrigger> config, object predicate, TTrigger trigger,
            AwaitableTransitionFlag flags)
        {
            Contract.NotNull(trigger != null, nameof(trigger));

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

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

            rep.NextStateRepresentationWrapper = null;
            rep.ConditionalTriggerPredicate    = predicate;
            rep.AwaitableTransitionFlags      |= flags;

            return(config);
        }
        internal static AwaitableStateConfiguration <TState, TTrigger> PermitDynamic <TState, TTrigger>(
            AwaitableStateConfiguration <TState, TTrigger> config, TTrigger trigger,
            object targetStateFunc,
            object onTriggerAction, AwaitableTransitionFlag flags)
        {
            Contract.NotNull(trigger != null, nameof(trigger));
            Contract.NotNull(targetStateFunc != null, nameof(targetStateFunc));

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

            rep.NextStateRepresentationWrapper = targetStateFunc;
            rep.OnTriggerAction             = onTriggerAction;
            rep.ConditionalTriggerPredicate = null;
            rep.AwaitableTransitionFlags   |= flags;

            return(config);
        }