Exemple #1
0
        /*
         * private int getNextState(int srcState, int action)
         * {
         *  var matchedRules = rules.Where(r => r.srcState == srcState && r.action == action);
         *  if (matchedRules.Count() > 0)
         *      return matchedRules.First().dstState;
         *  else
         *      return -1;
         * }*/

        public BotState getNextState(BotState srcState, string action)
        {
            var matchedRules = ruleNextActions.Where(r => r.srcState == srcState && r.action.isAction(action));

            if (matchedRules.Count() > 0)
            {
                return(matchedRules.First().dstState);
            }
            else
            {
                var elseRule = ruleNextActions.Where(r => r.srcState == srcState && r.action.GetType() == typeof(ElseAction));
                if (elseRule.Count() > 0)
                {
                    return(elseRule.First().dstState);
                }
                else
                {
                    return(BotStates.Invalid);
                }
            }
        }
Exemple #2
0
        public PostFunction getPostFunction(BotState preState, BotState nextState)
        {
            var spfList = rulePostFunctions.Where(spf => spf.preState == preState && spf.nextState == nextState);

            if (spfList.Count() > 0)
            {
                return(spfList.First().function);
            }
            else
            {
                spfList = rulePostFunctions.Where(spf => spf.preState == -1 && spf.nextState == nextState);
                if (spfList.Count() > 0)
                {
                    return(spfList.First().function);
                }
                else
                {
                    return (PostFunctionData pfd) => { }
                };
            }
        }
    }
Exemple #3
0
 public void addRulePostFunction(BotState newState, PostFunction function)
 {
     rulePostFunctions.Add(new RulePostFunction(newState, BotStates.Invalid, function));
 }
Exemple #4
0
 public void addRulePostFunction(BotState newState, BotState preState, PostFunction function)
 {
     rulePostFunctions.Add(new RulePostFunction(newState, preState, function));
 }
Exemple #5
0
 private void addRuleNextAction(BotState srcState, IAction action, BotState dstState)
 {
     ruleNextActions.Add(new RuleNextAction(srcState, action, dstState));
 }
Exemple #6
0
 public void addElseRule(BotState srcState, BotState dstState)
 {
     addRuleNextAction(srcState, new ElseAction(), dstState);
 }
Exemple #7
0
 public void addRegexRule(BotState srcState, string regexExpr, BotState dstState)
 {
     addRuleNextAction(srcState, new RegexAction(regexExpr), dstState);
 }
Exemple #8
0
 public void addRule(BotState srcState, BotState dstState)
 {
     addRuleNextAction(srcState, new LambdaAction(), dstState);
 }
Exemple #9
0
 public void addRule(BotState srcState, int action, BotState dstState)
 {
     addRuleNextAction(srcState, new NormalAction(action.ToString()), dstState);
 }
Exemple #10
0
 public void addRule(BotState srcState, string action, BotState dstState)
 {
     addRuleNextAction(srcState, new NormalAction(action), dstState);
 }
Exemple #11
0
 public RuleNextAction(BotState srcState, IAction action, BotState dstState)
 {
     this.srcState = srcState;
     this.action   = action;
     this.dstState = dstState;
 }