/// <summary>
        /// StateIterator constructor
        /// </summary>
        /// <param name="stateMachine">Instance of state machine.</param>
        /// <param name="filePath">Full path of the rule file.</param>
        public StateIterator(StateMachine.StateMachine <T> stateMachine, string filePath)
        {
            // TODO: Use Factory Pattern to generate this interpreter instance
            rulesInterpreter = new SCXMLInterpreter();
            rulesInterpreter.LoadRuleFile(filePath);
            rulesInterpreter.OnEvent(new OnDataEvent(this));

            this.stateMachine = stateMachine;
            this.iterator     = this.GetEnumerator();
        }
Exemple #2
0
        /// <summary>
        /// Method to process the input.
        /// TODO: Currently State Machine on a single match
        /// Will need immediate change
        /// </summary>
        /// <param name="interpreter">Rule Interpreter as provided by dependency injection.</param>
        /// <param name="input">Input object to process</param>
        /// <returns>Returns the State loaded after processing the input over the rule file.</returns>
        internal State <T> Process(IRuleInterpreter interpreter, T input)
        {
            inputBuffer.Add(input);
            List <IRule> nextRules
                = interpreter.LoadEvent <List <T> >(this.rule
                                                    , interpreter.CreateTransitionEvent <List <T> >(inputBuffer)
                                                    , Config <T> .GetInstance().stateMachineInputComparer);

            if (nextRules.Count == 0 ||
                nextRules[0].Name == this.Name)
            {
                return(this);
            }

            return(State <T> .Create(nextRules[0]));
        }