public Date(TemplateElementCollection format, TemplateElementCollection jformat, TemplateElementCollection locale, TemplateElementCollection timezone) { this.Format = format; this.JFormat = jformat; this.Locale = locale; this.Timezone = timezone; }
public Template(Bot bot, XmlNode xmlNode, TemplateElementCollection content, string?fileName) { this.Bot = bot; this.XmlNode = xmlNode; this.Content = content; this.FileName = fileName; }
public static TemplateNode.Bot FromXml(XmlNode node, AimlLoader loader) { // Search for XML attributes. XmlAttribute attribute; TemplateElementCollection?key = null; attribute = node.Attributes["name"]; if (attribute != null) { key = new TemplateElementCollection(attribute.Value); } // Search for properties in elements. foreach (XmlNode node2 in node.ChildNodes) { if (node2.NodeType == XmlNodeType.Element) { if (node2.Name.Equals("name", StringComparison.InvariantCultureIgnoreCase)) { key = TemplateElementCollection.FromXml(node2, loader); } } } if (key == null) { throw new AimlException("bot tag is missing a name property."); } return(new Bot(key)); }
public static TemplateNode.Input FromXml(XmlNode node, AimlLoader loader) { // Search for XML attributes. XmlAttribute attribute; TemplateElementCollection index = null; attribute = node.Attributes["index"]; if (attribute != null) { index = new TemplateElementCollection(attribute.Value); } // Search for properties in elements. foreach (XmlNode node2 in node.ChildNodes) { if (node2.NodeType == XmlNodeType.Element) { if (node2.Name.Equals("index", StringComparison.InvariantCultureIgnoreCase)) { index = TemplateElementCollection.FromXml(node2, loader); } } } return(new Input(index)); }
public static SraiX FromXml(XmlNode node, AimlLoader loader) { // Search for XML attributes. XmlAttribute attribute; string?serviceName = null; TemplateElementCollection?defaultReply = null; attribute = node.Attributes["service"]; if (attribute != null) { serviceName = attribute.Value; } attribute = node.Attributes["default"]; if (attribute != null) { defaultReply = new TemplateElementCollection(attribute.Value); } // Search for properties in elements. foreach (XmlNode node2 in node.ChildNodes) { if (node2.NodeType == XmlNodeType.Element) { if (node2.Name.Equals("default", StringComparison.InvariantCultureIgnoreCase)) { defaultReply = TemplateElementCollection.FromXml(node2, loader); } } } return(new SraiX(serviceName, node.Attributes, defaultReply, TemplateElementCollection.FromXml(node, loader))); }
public Interval(TemplateElementCollection jformat, TemplateElementCollection start, TemplateElementCollection end, TemplateElementCollection style) { this.JFormat = jformat; this.Start = start; this.End = end; this.Style = style; }
public static TemplateNode.Get FromXml(XmlNode node, AimlLoader loader) { // Search for XML attributes. XmlAttribute attribute; TemplateElementCollection key = null; bool localVar = false; TemplateElementCollection tupleKey = null; attribute = node.Attributes["name"]; if (attribute != null) { key = new TemplateElementCollection(attribute.Value); } else { attribute = node.Attributes["var"]; if (attribute != null) { key = new TemplateElementCollection(attribute.Value); localVar = true; } } attribute = node.Attributes["tuple"]; if (attribute != null) { tupleKey = new TemplateElementCollection(attribute.Value); } // Search for properties in elements. foreach (XmlNode node2 in node.ChildNodes) { if (node2.NodeType == XmlNodeType.Element) { if (node2.Name.Equals("name", StringComparison.InvariantCultureIgnoreCase)) { key = TemplateElementCollection.FromXml(node2, loader); localVar = false; } else if (node2.Name.Equals("var", StringComparison.InvariantCultureIgnoreCase)) { key = TemplateElementCollection.FromXml(node2, loader); localVar = true; } else if (node2.Name.Equals("tuple", StringComparison.InvariantCultureIgnoreCase)) { tupleKey = TemplateElementCollection.FromXml(node2, loader); } } } if (key == null) { throw new AimlException("get tag is missing a name or var property."); } return(new Get(key, tupleKey, localVar)); }
public Select(TemplateElementCollection variables, Clause[] clauses) { if (clauses.Length == 0) { throw new ArgumentException("A select tag must contain at least one clause.", "clauses"); } this.Variables = variables; this.Clauses = clauses; }
public static TemplateNode.Date FromXml(XmlNode node, AimlLoader loader) { // Search for XML attributes. XmlAttribute attribute; TemplateElementCollection format = null; TemplateElementCollection jformat = null; TemplateElementCollection locale = null; TemplateElementCollection timezone = null; attribute = node.Attributes["format"]; if (attribute != null) { format = new TemplateElementCollection(attribute.Value); } attribute = node.Attributes["jformat"]; if (attribute != null) { jformat = new TemplateElementCollection(attribute.Value); } attribute = node.Attributes["locale"]; if (attribute != null) { locale = new TemplateElementCollection(attribute.Value); } attribute = node.Attributes["timezone"]; if (attribute != null) { timezone = new TemplateElementCollection(attribute.Value); } // Search for properties in elements. foreach (XmlNode node2 in node.ChildNodes) { if (node2.NodeType == XmlNodeType.Element) { if (node2.Name.Equals("format", StringComparison.InvariantCultureIgnoreCase)) { format = TemplateElementCollection.FromXml(node2, loader); } else if (node2.Name.Equals("jformat", StringComparison.InvariantCultureIgnoreCase)) { jformat = TemplateElementCollection.FromXml(node2, loader); } else if (node2.Name.Equals("locale", StringComparison.InvariantCultureIgnoreCase)) { locale = TemplateElementCollection.FromXml(node2, loader); } else if (node2.Name.Equals("timezone", StringComparison.InvariantCultureIgnoreCase)) { timezone = TemplateElementCollection.FromXml(node2, loader); } } } return(new Date(format, jformat, locale, timezone)); }
public static Interval FromXml(XmlNode node, AimlLoader loader) { // Search for XML attributes. XmlAttribute attribute; TemplateElementCollection style = null; TemplateElementCollection jformat = null; TemplateElementCollection start = null; TemplateElementCollection end = null; attribute = node.Attributes["style"]; if (attribute != null) { style = new TemplateElementCollection(attribute.Value); } attribute = node.Attributes["jformat"]; if (attribute != null) { jformat = new TemplateElementCollection(attribute.Value); } attribute = node.Attributes["from"]; if (attribute != null) { start = new TemplateElementCollection(attribute.Value); } attribute = node.Attributes["to"]; if (attribute != null) { end = new TemplateElementCollection(attribute.Value); } // Search for properties in elements. foreach (XmlNode node2 in node.ChildNodes) { if (node2.NodeType == XmlNodeType.Element) { if (node2.Name.Equals("style", StringComparison.InvariantCultureIgnoreCase)) { style = TemplateElementCollection.FromXml(node2, loader); } else if (node2.Name.Equals("jformat", StringComparison.InvariantCultureIgnoreCase)) { jformat = TemplateElementCollection.FromXml(node2, loader); } else if (node2.Name.Equals("from", StringComparison.InvariantCultureIgnoreCase)) { start = TemplateElementCollection.FromXml(node2, loader); } else if (node2.Name.Equals("to", StringComparison.InvariantCultureIgnoreCase)) { end = TemplateElementCollection.FromXml(node2, loader); } } } return(new Interval(jformat, start, end, style)); }
public static Test FromXml(XmlNode node, AimlLoader loader) { // Search for XML attributes. XmlAttribute attribute; TemplateElementCollection?expected = null; List <TemplateNode> children = new List <TemplateNode>(); attribute = node.Attributes["name"]; if (attribute == null) { throw new AimlException("<test> tag must have a 'name' attribute."); } var name = attribute.Value; attribute = node.Attributes["expected"]; if (attribute != null) { expected = new TemplateElementCollection(attribute.Value); } // Search for properties in elements. foreach (XmlNode node2 in node.ChildNodes) { if (node2.NodeType == XmlNodeType.Whitespace) { children.Add(new TemplateText(" ")); } else if (node2.NodeType == XmlNodeType.Text || node2.NodeType == XmlNodeType.SignificantWhitespace) { children.Add(new TemplateText(node2.InnerText)); } else if (node2.NodeType == XmlNodeType.Element) { if (node2.Name.Equals("name", StringComparison.InvariantCultureIgnoreCase)) { throw new AimlException("<test> name may not be specified in a subtag."); } else if (node2.Name.Equals("expected", StringComparison.InvariantCultureIgnoreCase)) { expected = TemplateElementCollection.FromXml(node2, loader); } else { children.Add(loader.ParseElement(node2)); } } } if (expected == null) { throw new AimlException("<test> tag must have an 'expected' property."); } return(new Test(name, expected, new TemplateElementCollection(children.ToArray()))); }
public static Uniq FromXml(XmlNode node, AimlLoader loader) { List <Clause> clauses = new List <Clause>(); // Search for XML attributes. XmlAttribute attribute; TemplateElementCollection subj = null; TemplateElementCollection pred = null; TemplateElementCollection obj = null; attribute = node.Attributes["subj"]; if (attribute != null) { subj = new TemplateElementCollection(attribute.Value); } attribute = node.Attributes["pred"]; if (attribute != null) { pred = new TemplateElementCollection(attribute.Value); } attribute = node.Attributes["obj"]; if (attribute != null) { obj = new TemplateElementCollection(attribute.Value); } foreach (XmlNode node2 in node.ChildNodes) { if (node2.NodeType == XmlNodeType.Element) { if (node2.Name.Equals("subj", StringComparison.InvariantCultureIgnoreCase)) { subj = TemplateElementCollection.FromXml(node2, loader); } else if (node2.Name.Equals("pred", StringComparison.InvariantCultureIgnoreCase)) { pred = TemplateElementCollection.FromXml(node2, loader); } else if (node2.Name.Equals("obj", StringComparison.InvariantCultureIgnoreCase)) { obj = TemplateElementCollection.FromXml(node2, loader); } } } return(new Uniq(subj, pred, obj)); }
public static Map FromXml(XmlNode node, AimlLoader loader) { // Search for XML attributes. XmlAttribute attribute; TemplateElementCollection name = null; List <TemplateNode> children = new List <TemplateNode>(); attribute = node.Attributes["name"]; if (attribute != null) { name = new TemplateElementCollection(attribute.Value); } // Search for properties in elements. foreach (XmlNode node2 in node.ChildNodes) { if (node2.NodeType == XmlNodeType.Whitespace) { children.Add(new TemplateText(" ")); } else if (node2.NodeType == XmlNodeType.Text || node2.NodeType == XmlNodeType.SignificantWhitespace) { children.Add(new TemplateText(node2.InnerText)); } else if (node2.NodeType == XmlNodeType.Element) { if (node2.Name.Equals("name", StringComparison.InvariantCultureIgnoreCase)) { name = TemplateElementCollection.FromXml(node2, loader); } else { children.Add(loader.ParseElement(node2)); } } } if (name == null) { throw new AimlException("map tag is missing a name property."); } return(new Map(name, new TemplateElementCollection(children.ToArray()))); }
public void ProcessCategory(PatternNode target, XmlNode node, string topicName, string filename) { XmlNode?patternNode = null, templateNode = null, thatNode = null, topicNode = null; foreach (XmlNode node2 in node.ChildNodes) { if (node2.Name.Equals("pattern", StringComparison.InvariantCultureIgnoreCase)) { patternNode = node2; } else if (node2.Name.Equals("template", StringComparison.InvariantCultureIgnoreCase)) { templateNode = node2; } else if (node2.Name.Equals("that", StringComparison.InvariantCultureIgnoreCase)) { thatNode = node2; } else if (node2.Name.Equals("topic", StringComparison.InvariantCultureIgnoreCase)) { topicNode = node2; } } if (patternNode == null) { throw new AimlException("Missing pattern tag in a node found in " + filename + "."); } if (templateNode == null) { throw new AimlException("Node missing a template, with pattern '" + patternNode.InnerXml + "' in file " + filename + "."); } if (string.IsNullOrWhiteSpace(patternNode.InnerXml)) { this.bot.Log(LogLevel.Warning, "Attempted to load a new category with an empty pattern, with template '" + templateNode.OuterXml + " in file " + filename + "." ); } // Parse the template. var templateContent = TemplateElementCollection.FromXml(templateNode, this); target.AddChild(this.GeneratePath(patternNode, thatNode, topicNode, topicName, false), new Template(this.bot, templateNode, templateContent, filename)); ++bot.Size; }
private void ProcessXml(XmlNode node, RequestProcess process) { for (int i = 0; i < node.ChildNodes.Count; ++i) { XmlNode node2 = node.ChildNodes[i]; if (node2.NodeType == XmlNodeType.Element) { if (node2.Name.Equals("eval", StringComparison.InvariantCultureIgnoreCase)) { TemplateElementCollection tags = TemplateElementCollection.FromXml(node2, process.Bot.AimlLoader); node2.ParentNode.ReplaceChild(node.OwnerDocument.CreateTextNode(tags.Evaluate(process)), node2); } else { this.ProcessXml(node2, process); } } } }
public static Select FromXml(XmlNode node, AimlLoader loader) { List <Clause> clauses = new List <Clause>(); // Search for XML attributes. XmlAttribute attribute; TemplateElementCollection variables = null; attribute = node.Attributes["vars"]; if (attribute != null) { variables = new TemplateElementCollection(attribute.Value); } foreach (XmlNode node2 in node.ChildNodes) { if (node2.NodeType == XmlNodeType.Element) { if (node2.Name.Equals("vars", StringComparison.InvariantCultureIgnoreCase)) { variables = TemplateElementCollection.FromXml(node2, loader); } else if (node2.Name.Equals("q", StringComparison.InvariantCultureIgnoreCase)) { clauses.Add(Clause.FromXml(node2, true, loader)); } else if (node2.Name.Equals("notq", StringComparison.InvariantCultureIgnoreCase)) { clauses.Add(Clause.FromXml(node2, false, loader)); } } } return(new Select(variables, clauses.ToArray())); }
public First(TemplateElementCollection children) : base(children) { }
public static First FromXml(XmlNode node, AimlLoader loader) { return(new First(TemplateElementCollection.FromXml(node, loader))); }
public Set(TemplateElementCollection key, bool local, TemplateElementCollection children) : base(children) { this.Key = key; this.LocalVar = local; }
public static Person2 FromXml(XmlNode node, AimlLoader loader) { return(new Person2(TemplateElementCollection.FromXml(node, loader))); }
public Person2(TemplateElementCollection children) : base(children) { }
public static TemplateNode.Lowercase FromXml(XmlNode node, AimlLoader loader) { return(new Lowercase(TemplateElementCollection.FromXml(node, loader))); }
public Lowercase(TemplateElementCollection children) : base(children) { }
public Gossip(TemplateElementCollection children) : base(children) { }
public static Gossip FromXml(XmlNode node, AimlLoader loader) { return(new Gossip(TemplateElementCollection.FromXml(node, loader))); }
public Input(TemplateElementCollection index) { this.Index = index; }
public static Explode FromXml(XmlNode node, AimlLoader loader) { return(new Explode(TemplateElementCollection.FromXml(node, loader))); }
public Explode(TemplateElementCollection children) : base(children) { }
public static TemplateNode.Random.li Parse(XmlNode node, AimlLoader loader) { return(new li(TemplateElementCollection.FromXml(node, loader))); }
public Date(TemplateElementCollection format, TemplateElementCollection jformat) : this(format, jformat, null, null) { }