Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HighlightRuleSet"/> class.
        /// </summary>
        /// <param name="el">The XML element that describes the rule set.</param>
        public HighlightRuleSet(XmlElement el)
        {
            if (el.Attributes["name"] != null)
            {
                Name = el.Attributes["name"].InnerText;
            }

            if (el.HasAttribute("escapecharacter"))
            {
                escapeCharacter = el.GetAttribute("escapecharacter")[0];
            }

            if (el.Attributes["reference"] != null)
            {
                reference = el.Attributes["reference"].InnerText;
            }

            if (el.Attributes["ignorecase"] != null)
            {
                ignoreCase = Boolean.Parse(el.Attributes["ignorecase"].InnerText);
            }

            if (el.Attributes["highlightDigits"] != null)
            {
                highlightDigits = Boolean.Parse(el.Attributes["highlightDigits"].InnerText);
            }

            for (int i = 0; i < Delimiters.Length; ++i)
            {
                delimiters[i] = false;
            }

            if (el["Delimiters"] != null)
            {
                string delimiterString = el["Delimiters"].InnerText;
                foreach (char ch in delimiterString)
                {
                    delimiters[ch] = true;
                }
            }

            keyWords    = new LookupTable(!IgnoreCase);
            prevMarkers = new LookupTable(!IgnoreCase);
            nextMarkers = new LookupTable(!IgnoreCase);

            XmlNodeList nodes = el.GetElementsByTagName("KeyWords");

            foreach (XmlElement el2 in nodes)
            {
                HighlightColor color = new HighlightColor(el2);

                XmlNodeList keys = el2.GetElementsByTagName("Key");
                foreach (XmlElement node in keys)
                {
                    keyWords[node.Attributes["word"].InnerText] = color;
                }
            }

            nodes = el.GetElementsByTagName("Span");
            foreach (XmlElement el2 in nodes)
            {
                Spans.Add(new Span(el2));
            }

            nodes = el.GetElementsByTagName("MarkPrevious");
            foreach (XmlElement el2 in nodes)
            {
                PrevMarker prev = new PrevMarker(el2);
                prevMarkers[prev.What] = prev;
            }

            nodes = el.GetElementsByTagName("MarkFollowing");
            foreach (XmlElement el2 in nodes)
            {
                NextMarker next = new NextMarker(el2);
                nextMarkers[next.What] = next;
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="HighlightRuleSet"/> class.
        /// </summary>
        /// <param name="el">The XML element that describes the rule set.</param>
        public HighlightRuleSet(XmlElement el)
        {
            if (el.Attributes["name"] != null)
            Name = el.Attributes["name"].InnerText;

              if (el.HasAttribute("escapecharacter"))
            escapeCharacter = el.GetAttribute("escapecharacter")[0];

              if (el.Attributes["reference"] != null)
            reference = el.Attributes["reference"].InnerText;

              if (el.Attributes["ignorecase"] != null)
            ignoreCase = Boolean.Parse(el.Attributes["ignorecase"].InnerText);

              if (el.Attributes["highlightDigits"] != null)
            highlightDigits = Boolean.Parse(el.Attributes["highlightDigits"].InnerText);

              for (int i = 0; i < Delimiters.Length; ++i)
            delimiters[i] = false;

              if (el["Delimiters"] != null)
              {
            string delimiterString = el["Delimiters"].InnerText;
            foreach (char ch in delimiterString)
              delimiters[ch] = true;
              }

              keyWords = new LookupTable(!IgnoreCase);
              prevMarkers = new LookupTable(!IgnoreCase);
              nextMarkers = new LookupTable(!IgnoreCase);

              XmlNodeList nodes = el.GetElementsByTagName("KeyWords");
              foreach (XmlElement el2 in nodes)
              {
            HighlightColor color = new HighlightColor(el2);

            XmlNodeList keys = el2.GetElementsByTagName("Key");
            foreach (XmlElement node in keys)
            {
              keyWords[node.Attributes["word"].InnerText] = color;
            }
              }

              nodes = el.GetElementsByTagName("Span");
              foreach (XmlElement el2 in nodes)
            Spans.Add(new Span(el2));

              nodes = el.GetElementsByTagName("MarkPrevious");
              foreach (XmlElement el2 in nodes)
              {
            PrevMarker prev = new PrevMarker(el2);
            prevMarkers[prev.What] = prev;
              }

              nodes = el.GetElementsByTagName("MarkFollowing");
              foreach (XmlElement el2 in nodes)
              {
            NextMarker next = new NextMarker(el2);
            nextMarkers[next.What] = next;
              }
        }