当前位置: 首页>>代码示例>>C#>>正文


C# XmlNode.SelectChatBotNodes方法代码示例

本文整理汇总了C#中System.Xml.XmlNode.SelectChatBotNodes方法的典型用法代码示例。如果您正苦于以下问题:C# XmlNode.SelectChatBotNodes方法的具体用法?C# XmlNode.SelectChatBotNodes怎么用?C# XmlNode.SelectChatBotNodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.XmlNode的用法示例。


在下文中一共展示了XmlNode.SelectChatBotNodes方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateRuleFromXml

        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
            );
        }
开发者ID:ZachWhitford,项目名称:ChatBot,代码行数:17,代码来源:ReplacementBotRule.cs

示例2: GetRulePattern

 public string GetRulePattern(XmlNode node)
 {
     foreach (XmlNode subnode in node.SelectChatBotNodes("cb:Pattern"))
     {
         return subnode.InnerText;
     }
     return "";
 }
开发者ID:ZachWhitford,项目名称:ChatBot,代码行数:8,代码来源:ChatBotRuleGenerator.cs

示例3: CreateRuleFromXml

 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
     );
 }
开发者ID:ZachWhitford,项目名称:ChatBot,代码行数:9,代码来源:PowershellBotRule.cs

示例4: CreateRuleFromXml

 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()
     );
 }
开发者ID:ZachWhitford,项目名称:ChatBot,代码行数:9,代码来源:RandomAnswersBotRule.cs

示例5: GetRuleWeight

 public int GetRuleWeight(XmlNode node)
 {
     int weight = -100;
     foreach (XmlNode subnode in node.SelectChatBotNodes("cb:Weight"))
     {
         if (Int32.TryParse(subnode.InnerText.Trim(), out weight))
         {
             return weight;
         }
     }
     return weight;
 }
开发者ID:ZachWhitford,项目名称:ChatBot,代码行数:12,代码来源:ChatBotRuleGenerator.cs

示例6: CreateRuleFromXml

        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);
                }
               );
        }
开发者ID:ZachWhitford,项目名称:ChatBot,代码行数:13,代码来源:BotRule.cs

示例7: CreateRuleFromXml

        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)
            );
        }
开发者ID:ZachWhitford,项目名称:ChatBot,代码行数:48,代码来源:ConditionBotRule.cs

示例8: Parse

        public List<BotRule> Parse(XmlDocument document, XmlNode startNode=null)
        {
            List<BotRule> liste = new List<BotRule>();
            if (startNode == null)
            {
                foreach (XmlNode node in document.SelectChatBotNodes("/cb:ChatBot/cb:Rules/cb:Rule"))
                {
                    BotRule rule = ProcessNode(node);
                    if (rule != null)
                    {
                        liste.Add(rule);
                    }
                }
            }
            else
            {
                foreach (XmlNode node in startNode.SelectChatBotNodes("cb:Rules/cb:Rule"))
                {
                    BotRule rule = ProcessNode(node);
                    if (rule != null)
                    {
                        liste.Add(rule);
                    }
                }
            }

            return liste;
        }
开发者ID:ZachWhitford,项目名称:ChatBot,代码行数:28,代码来源:ChatBotRuleGenerator.cs


注:本文中的System.Xml.XmlNode.SelectChatBotNodes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。