Ejemplo n.º 1
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);
        }