Beispiel #1
0
        private static RuleDesc ParseRule(XmlNode ruleNode, Dictionary <string, Style> styles)
        {
            RuleDesc rule = new RuleDesc();

            rule.pattern = ruleNode.InnerText;
            //
            var styleA   = ruleNode.Attributes["style"];
            var optionsA = ruleNode.Attributes["options"];

            //Style
            if (styleA == null)
            {
                throw new Exception("Rule must contain style name.");
            }
            if (!styles.ContainsKey(styleA.Value))
            {
                throw new Exception("Style '" + styleA.Value + "' is not found.");
            }
            rule.style = styles[styleA.Value];
            //options
            if (optionsA != null)
            {
                rule.options = (RegexOptions)Enum.Parse(typeof(RegexOptions), optionsA.Value);
            }

            return(rule);
        }
        private static RuleDesc ParseRule(XmlNode ruleNode, Dictionary<string, Style> styles)
        {
            RuleDesc rule = new RuleDesc();
            rule.pattern = ruleNode.InnerText;
            //
            var styleA = ruleNode.Attributes["style"];
            var optionsA = ruleNode.Attributes["options"];
            //Style
            if (styleA == null)
                throw new Exception("Rule must contain style name.");
            if(!styles.ContainsKey(styleA.Value))
                throw new Exception("Style '"+styleA.Value+"' is not found.");
            rule.style = styles[styleA.Value];
            //options
            if (optionsA != null)
                rule.options = (RegexOptions)Enum.Parse(typeof(RegexOptions), optionsA.Value);

            return rule;
        }