本文整理汇总了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
);
}
示例2: GetRulePattern
public string GetRulePattern(XmlNode node)
{
foreach (XmlNode subnode in node.SelectChatBotNodes("cb:Pattern"))
{
return subnode.InnerText;
}
return "";
}
示例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
);
}
示例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()
);
}
示例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;
}
示例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);
}
);
}
示例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)
);
}
示例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;
}