Esempio n. 1
0
 private StateSpecifier InternalPermitIf(TTriggerType trigger, TStateType destinationState,
                                         Func <bool> triggerCondition)
 {
     _specification.AddTriggerStrategy(new StateTransitionTriggerStrategy(trigger, destinationState,
                                                                          triggerCondition));
     return(this);
 }
Esempio n. 2
0
 private StateSpecifier PermitIfInternal(TTriggerType trigger,
                                         Func <object[], TStateType> destinationStateSelector,
                                         Func <bool> triggerCondition)
 {
     _specification.AddTriggerStrategy(new DestinationFunctionTriggerStrategy(trigger,
                                                                              destinationStateSelector,
                                                                              triggerCondition));
     return(this);
 }
 public void AddEntryAction(TTriggerType trigger, Action <StateTransition, object[]> action)
 {
     _entryActions.Add((t, args) =>
     {
         if (t.Trigger.Equals(trigger))
         {
             action(t, args);
         }
     });
 }
            private bool HasLocalHandlerFor(TTriggerType trigger, out TriggerStrategy handler)
            {
                ICollection <TriggerStrategy> possible;

                if (!_triggerStrategies.TryGetValue(trigger, out possible))
                {
                    handler = null;
                    return(false);
                }

                var actual = possible.Where(at => at.ConditionPositive).ToArray();

                if (actual.Count() > 1)
                {
                    throw new InvalidOperationException(
                              string.Format("Ambiguous trigger transition on trigger {0} on state {1}",
                                            trigger, _state));
                }

                handler = actual.FirstOrDefault();
                return(handler != null);
            }
Esempio n. 5
0
 private StateSpecifier InternalPermitDynamic(TTriggerType trigger,
                                              Func <object[], TStateType> destinationStateSelector)
 {
     return(PermitIfInternal(trigger, destinationStateSelector, Promiscuous));
 }
Esempio n. 6
0
 public override void Trigger(TTriggerType trigger, TTriggerData data)
 {
     Universe.GetComponents <TComponent>()
     .ForAll(component => OnTrigger(trigger, data, component as TComponent));
 }
Esempio n. 7
0
 public StateTransition(TStateType source, TStateType destination, TTriggerType trigger)
 {
     _source      = source;
     _destination = destination;
     _trigger     = trigger;
 }
Esempio n. 8
0
 public StateSpecifier OnEntryFrom(TTriggerType trigger, Action <StateTransition> entryAction)
 {
     _specification.AddEntryAction(trigger, (t, args) => entryAction(t));
     return(this);
 }
Esempio n. 9
0
 public StateSpecifier IgnoreIf(TTriggerType trigger, Func <bool> triggerCondition)
 {
     _specification.AddTriggerStrategy(new IgnoredTriggerStrategy(trigger, triggerCondition));
     return(this);
 }
Esempio n. 10
0
 public StateSpecifier PermitReentryIf(TTriggerType trigger, Func <bool> triggerCondition)
 {
     return(InternalPermitIf(trigger, _specification.UnderlyingState, triggerCondition));
 }
Esempio n. 11
0
 public StateSpecifier PermitIf(TTriggerType trigger, TStateType destinationState,
                                Func <bool> triggerCondition)
 {
     EnforceNotIdentityTransition(destinationState);
     return(InternalPermitIf(trigger, destinationState, triggerCondition));
 }
 public bool HasHandlerFor(TTriggerType trigger, out TriggerStrategy handler)
 {
     return(HasLocalHandlerFor(trigger, out handler) ||
            (Superstate != null && Superstate.HasHandlerFor(trigger, out handler)));
 }
            public bool CanHandle(TTriggerType trigger)
            {
                TriggerStrategy unused;

                return(HasHandlerFor(trigger, out unused));
            }
Esempio n. 14
0
 public abstract void OnTrigger(TTriggerType trigger, TTriggerData data, TEntity entity);
Esempio n. 15
0
 public override void Trigger(TTriggerType trigger, TTriggerData data)
 {
     Universe.GetEntities <TEntity>().ForAll(entity => OnTrigger(trigger, data, entity));
 }
Esempio n. 16
0
 public abstract void OnTrigger(TTriggerType trigger, TTriggerData data, TComponent component);
Esempio n. 17
0
 public StateSpecifier Permit(TTriggerType trigger, TStateType destinationState)
 {
     EnforceNotIdentityTransition(destinationState);
     return(InternalPermit(trigger, destinationState));
 }
Esempio n. 18
0
 public StateTransitionTriggerStrategy(TTriggerType trigger, TStateType destination,
                                       Func <bool> triggerCondition)
     : base(trigger, triggerCondition)
 {
     _destination = destination;
 }
Esempio n. 19
0
 public StateSpecifier PermitReentry(TTriggerType trigger)
 {
     return(InternalPermit(trigger, _specification.UnderlyingState));
 }
Esempio n. 20
0
 public IgnoredTriggerStrategy(TTriggerType trigger, Func <bool> triggerCondition)
     : base(trigger, triggerCondition)
 {
 }
Esempio n. 21
0
 public StateSpecifier Ignore(TTriggerType trigger)
 {
     return(IgnoreIf(trigger, Promiscuous));
 }
Esempio n. 22
0
 public StateSpecifier Permit(TTriggerType trigger, Func <TStateType> destinationStateSelector)
 {
     return(PermitIf(trigger, destinationStateSelector, Promiscuous));
 }
Esempio n. 23
0
 public StateSpecifier OnEntryFrom(TTriggerType trigger, Action entryAction)
 {
     return(OnEntryFrom(trigger, t => entryAction()));
 }
Esempio n. 24
0
 public StateSpecifier PermitIf(TTriggerType trigger, Func <TStateType> destinationStateSelector,
                                Func <bool> triggerCondition)
 {
     return(PermitIfInternal(trigger, args => destinationStateSelector(), triggerCondition));
 }
Esempio n. 25
0
 protected TriggerStrategy(TTriggerType trigger, Func <bool> triggerCondition)
 {
     _trigger          = trigger;
     _triggerCondition = triggerCondition;
 }
Esempio n. 26
0
 private StateSpecifier InternalPermit(TTriggerType trigger, TStateType destinationState)
 {
     return(InternalPermitIf(trigger, destinationState, () => true));
 }
 public DestinationFunctionTriggerStrategy(TTriggerType trigger, Func <object[], TStateType> destination,
                                           Func <bool> triggerCondition)
     : base(trigger, triggerCondition)
 {
     _destination = destination;
 }
 public ParameterizedTrigger(TTriggerType underlyingTrigger, params Type[] argumentTypes)
 {
     _underlyingTrigger = underlyingTrigger;
     _argumentTypes     = argumentTypes;
 }