Example #1
0
 /// <exception cref="FsmBuilderException">When the initial state is null</exception>
 public Fsm(State <TS, TT> current, bool stackEnabled = false)
 {
     Model.StackEnabled = stackEnabled;
     Model.Current      = current ?? throw FsmBuilderException.StateCannotBeNull();
     if (Model.StackEnabled && !current.ClearStack)
     {
         Model.Stack.Push(current);
     }
 }
Example #2
0
        /// <exception cref="FsmBuilderException">When the state is null or the state has already been added before</exception>
        public Fsm <TS, TT> Add(State <TS, TT> state)
        {
            if (state == null)
            {
                throw FsmBuilderException.StateCannotBeNull();
            }
            if (Model.States.ContainsKey(state.Identifier))
            {
                throw FsmBuilderException.StateCanOnlyBeAddedOnce(state);
            }

            Model.States.Add(state.Identifier, state);
            return(this);
        }