예제 #1
0
 object IXshdVisitor.VisitKeywords(XshdKeywords keywords)
 {
     writer.WriteStartElement("Keywords", Namespace);
     WriteColorReference(keywords.ColorReference);
     foreach (string word in keywords.Words) {
         writer.WriteElementString("Word", Namespace, word);
     }
     writer.WriteEndElement();
     return null;
 }
예제 #2
0
 static XshdKeywords ParseKeywords(XmlReader reader)
 {
     XshdKeywords keywords = new XshdKeywords();
     SetPosition(keywords, reader);
     keywords.ColorReference = ParseColorReference(reader);
     reader.Read();
     while (reader.NodeType != XmlNodeType.EndElement) {
         Debug.Assert(reader.NodeType == XmlNodeType.Element);
         keywords.Words.Add(reader.ReadElementString());
     }
     return keywords;
 }
예제 #3
0
        XshdRuleSet ImportRuleSet(XmlElement element)
        {
            XshdRuleSet ruleSet = new XshdRuleSet();
            ruleSet.Name = element.GetAttributeOrNull("name");

            if (element.HasAttribute("escapecharacter")) {
                ruleSetEscapeCharacter = element.GetAttribute("escapecharacter")[0];
            } else {
                ruleSetEscapeCharacter = '\0';
            }

            if (element.HasAttribute("reference")) {
                ruleSet.Elements.Add(
                    new XshdImport { RuleSetReference = new XshdReference<XshdRuleSet>(
                        element.GetAttribute("reference"), string.Empty
                    ) });
            }
            ruleSet.IgnoreCase = element.GetBoolAttribute("ignorecase");

            foreach (XmlElement el in element.GetElementsByTagName("KeyWords")) {
                XshdKeywords keywords = new XshdKeywords();
                keywords.ColorReference = GetColorReference(el);
                // we have to handle old syntax highlighting definitions that contain
                // empty keywords or empty keyword groups
                foreach (XmlElement node in el.GetElementsByTagName("Key")) {
                    string word = node.GetAttribute("word");
                    if (!string.IsNullOrEmpty(word))
                        keywords.Words.Add(word);
                }
                if (keywords.Words.Count > 0) {
                    ruleSet.Elements.Add(keywords);
                }
            }

            foreach (XmlElement el in element.GetElementsByTagName("Span")) {
                ruleSet.Elements.Add(ImportSpan(el));
            }

            foreach (XmlElement el in element.GetElementsByTagName("MarkPrevious")) {
                ruleSet.Elements.Add(ImportMarkPrevNext(el, false));
            }
            foreach (XmlElement el in element.GetElementsByTagName("MarkFollowing")) {
                ruleSet.Elements.Add(ImportMarkPrevNext(el, true));
            }

            return ruleSet;
        }