예제 #1
0
 new public static BotRule CreateRuleFromXml(ChatBotRuleGenerator generator, XmlNode node)
 {
     return(new PowershellBotRule(
                generator.GetRuleName(node),
                generator.GetRuleWeight(node),
                new Regex(generator.GetRulePattern(node)),
                node.SelectChatBotNodes("cb:Script").Cast <XmlNode>().First().InnerText
                ));
 }
예제 #2
0
 public static new BotRule CreateRuleFromXml(ChatBotRuleGenerator generator, XmlNode node)
 {
     return new PowershellBotRule(
         generator.GetRuleName(node),
         generator.GetRuleWeight(node),
         new Regex(generator.GetRulePattern(node)),
         node.SelectChatBotNodes("cb:Script").Cast<XmlNode>().First().InnerText
     );
 }
예제 #3
0
 new public static BotRule CreateRuleFromXml(ChatBotRuleGenerator generator, XmlNode node)
 {
     return(new RandomAnswersBotRule(
                generator.GetRuleName(node),
                generator.GetRuleWeight(node),
                new Regex(generator.GetRulePattern(node)),
                node.SelectChatBotNodes("cb:Messages/cb:Message").Cast <XmlNode>().Select(n => n.InnerText).ToArray()
                ));
 }
예제 #4
0
 public static new BotRule CreateRuleFromXml(ChatBotRuleGenerator generator, XmlNode node)
 {
     return new RandomAnswersBotRule(
         generator.GetRuleName(node),
         generator.GetRuleWeight(node),
         new Regex(generator.GetRulePattern(node)),
         node.SelectChatBotNodes("cb:Messages/cb:Message").Cast<XmlNode>().Select(n => n.InnerText).ToArray()
     );
 }
예제 #5
0
        new public static BotRule CreateRuleFromXml(ChatBotRuleGenerator generator, XmlNode node)
        {
            // get unique setters
            List <Tuple <string, Operator, string> > conditions = new List <Tuple <string, Operator, string> >();

            foreach (XmlNode subnode in node.SelectChatBotNodes("cb:Conditions/cb:Condition").Cast <XmlNode>().Where(n => n.Attributes["Key"] != null && n.Attributes["Operator"] != null))
            {
                switch (subnode.Attributes["Operator"].Value.Trim().ToLower())
                {
                case "equal":
                case "eq":
                    conditions.Add(new Tuple <string, Operator, string>(subnode.Attributes["Key"].Value, Operator.Equal, subnode.InnerText));
                    break;

                case "equalignorecase":
                case "ieq":
                    conditions.Add(new Tuple <string, Operator, string>(subnode.Attributes["Key"].Value, Operator.EqualIgnoreCase, subnode.InnerText));
                    break;

                case "notequal":
                case "ne":
                    conditions.Add(new Tuple <string, Operator, string>(subnode.Attributes["Key"].Value, Operator.NotEqual, subnode.InnerText));
                    break;

                case "notequalignorecase":
                case "ine":
                    conditions.Add(new Tuple <string, Operator, string>(subnode.Attributes["Key"].Value, Operator.NotEqualIgnoreCase, subnode.InnerText));
                    break;

                case "containskey":
                case "ck":
                    conditions.Add(new Tuple <string, Operator, string>(subnode.Attributes["Key"].Value, Operator.ContainsKey, subnode.InnerText));
                    break;

                case "containsvalue":
                case "cv":
                    conditions.Add(new Tuple <string, Operator, string>(subnode.Attributes["Key"].Value, Operator.ContainsValue, subnode.InnerText));
                    break;

                case "containsvalueignorecase":
                case "icv":
                    conditions.Add(new Tuple <string, Operator, string>(subnode.Attributes["Key"].Value, Operator.ContainsValueIgnoreCase, subnode.InnerText));
                    break;
                }
            }

            return(new ConditionBotRule(
                       generator.GetRuleName(node),
                       generator.GetRuleWeight(node),
                       conditions,
                       generator.Parse(node.OwnerDocument, node)
                       ));
        }
        public static BotRule CreateRuleFromXml(ChatBotRuleGenerator generator, XmlNode node)
        {
            BotRuleCodeCompiler brcc = new BotRuleCodeCompiler(node.SelectChatBotNodes("cb:Process").Cast <XmlNode>().First().InnerText);

            return(new BotRule(
                       generator.GetRuleName(node),
                       generator.GetRuleWeight(node),
                       new Regex(generator.GetRulePattern(node)),
                       delegate(Match match, ChatSessionInterface session) {
                return brcc.Execute(match, session);
            }
                       ));
        }
예제 #7
0
        public static new BotRule CreateRuleFromXml(ChatBotRuleGenerator generator, XmlNode node)
        {
            // get unique setters
            Dictionary<string, string> setters = new Dictionary<string, string>();
            foreach (XmlNode subnode in node.SelectChatBotNodes("cb:Setters/cb:Set").Cast<XmlNode>().Where(n => n.Attributes["Key"] != null))
            {
                setters[subnode.Attributes["Key"].Value] = subnode.InnerText;
            }

            return new ReplacementBotRule(
                generator.GetRuleName(node),
                generator.GetRuleWeight(node),
                new Regex(generator.GetRulePattern(node)),
                node.SelectChatBotNodes("cb:Messages/cb:Message").Cast<XmlNode>().Select(n => n.InnerText).ToArray(),
                setters
            );
        }
        new public static BotRule CreateRuleFromXml(ChatBotRuleGenerator generator, XmlNode node)
        {
            // get unique setters
            Dictionary <string, string> setters = new Dictionary <string, string>();

            foreach (XmlNode subnode in node.SelectChatBotNodes("cb:Setters/cb:Set").Cast <XmlNode>().Where(n => n.Attributes["Key"] != null))
            {
                setters[subnode.Attributes["Key"].Value] = subnode.InnerText;
            }

            return(new ReplacementBotRule(
                       generator.GetRuleName(node),
                       generator.GetRuleWeight(node),
                       new Regex(generator.GetRulePattern(node)),
                       node.SelectChatBotNodes("cb:Messages/cb:Message").Cast <XmlNode>().Select(n => n.InnerText).ToArray(),
                       setters
                       ));
        }
예제 #9
0
        public static BotRule CreateRuleFromXml(ChatBotRuleGenerator generator, XmlNode node)
        {
            BotRuleCodeCompiler brcc = new BotRuleCodeCompiler(node.SelectChatBotNodes("cb:Process").Cast<XmlNode>().First().InnerText);

            return new BotRule(
                generator.GetRuleName(node),
                generator.GetRuleWeight(node),
                new Regex(generator.GetRulePattern(node)),
                delegate(Match match, ChatSessionInterface session) {
                    return brcc.Execute(match, session);
                }
               );
        }
예제 #10
0
        public static new BotRule CreateRuleFromXml(ChatBotRuleGenerator generator, XmlNode node)
        {
            // get unique setters
            List<Tuple<string, Operator, string>> conditions = new List<Tuple<string, Operator, string>>();
            foreach (XmlNode subnode in node.SelectChatBotNodes("cb:Conditions/cb:Condition").Cast<XmlNode>().Where(n => n.Attributes["Key"] != null && n.Attributes["Operator"] != null))
            {
                switch (subnode.Attributes["Operator"].Value.Trim().ToLower())
                {
                    case "equal":
                    case "eq":
                        conditions.Add(new Tuple<string, Operator, string>(subnode.Attributes["Key"].Value, Operator.Equal, subnode.InnerText));
                        break;
                    case "equalignorecase":
                    case "ieq":
                        conditions.Add(new Tuple<string, Operator, string>(subnode.Attributes["Key"].Value, Operator.EqualIgnoreCase, subnode.InnerText));
                        break;
                    case "notequal":
                    case "ne":
                        conditions.Add(new Tuple<string, Operator, string>(subnode.Attributes["Key"].Value, Operator.NotEqual, subnode.InnerText));
                        break;
                    case "notequalignorecase":
                    case "ine":
                        conditions.Add(new Tuple<string, Operator, string>(subnode.Attributes["Key"].Value, Operator.NotEqualIgnoreCase, subnode.InnerText));
                        break;
                    case "containskey":
                    case "ck":
                        conditions.Add(new Tuple<string, Operator, string>(subnode.Attributes["Key"].Value, Operator.ContainsKey, subnode.InnerText));
                        break;
                    case "containsvalue":
                    case "cv":
                        conditions.Add(new Tuple<string, Operator, string>(subnode.Attributes["Key"].Value, Operator.ContainsValue, subnode.InnerText));
                        break;
                    case "containsvalueignorecase":
                    case "icv":
                        conditions.Add(new Tuple<string, Operator, string>(subnode.Attributes["Key"].Value, Operator.ContainsValueIgnoreCase, subnode.InnerText));
                        break;

                }

            }

            return new ConditionBotRule(
                generator.GetRuleName(node),
                generator.GetRuleWeight(node),
                conditions,
                generator.Parse(node.OwnerDocument, node)
            );
        }