internal static StateInfo CreateStateInfo <TState, TTrigger>(StateMachine <TState, TTrigger> .StateRepresentation stateRepresentation) { if (stateRepresentation == null) { throw new ArgumentException(nameof(stateRepresentation)); } var ignoredTriggers = new List <IgnoredTransitionInfo>(); // stateRepresentation.TriggerBehaviours maps from TTrigger to ICollection<TriggerBehaviour> foreach (var triggerBehaviours in stateRepresentation.TriggerBehaviours) { foreach (var item in triggerBehaviours.Value) { if (item is StateMachine <TState, TTrigger> .IgnoredTriggerBehaviour) { ignoredTriggers.Add(IgnoredTransitionInfo.Create((StateMachine <TState, TTrigger> .IgnoredTriggerBehaviour)item)); } } } return(new StateInfo(stateRepresentation.UnderlyingState, ignoredTriggers, stateRepresentation.EntryActions.Select(e => ActionInfo.Create(e)).ToList(), stateRepresentation.ActivateActions.Select(e => e.Description).ToList(), stateRepresentation.DeactivateActions.Select(e => e.Description).ToList(), stateRepresentation.ExitActions.Select(e => e.Description).ToList())); }
internal static IgnoredTransitionInfo Create <TState, TTrigger>(StateMachine <TState, TTrigger> .IgnoredTriggerBehaviour behaviour) { var transition = new IgnoredTransitionInfo { Trigger = new TriggerInfo(behaviour.Trigger), GuardConditionsMethodDescriptions = (behaviour.Guard == null) ? new List <InvocationInfo>() : behaviour.Guard.Conditions.Select(c => c.MethodDescription) }; return(transition); }