Пример #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;
        }
 protected static RuleDesc ParseRule(XmlNode ruleNode, Dictionary<string, Style> styles)
 {
     var ruleDesc = new RuleDesc();
     ruleDesc.pattern = ruleNode.InnerText;
     var xmlAttribute = ruleNode.Attributes["style"];
     var xmlAttribute2 = ruleNode.Attributes["options"];
     var flag = xmlAttribute == null;
     if (flag)
     {
         throw new Exception("Rule must contain style name.");
     }
     var flag2 = !styles.ContainsKey(xmlAttribute.Value);
     if (flag2)
     {
         throw new Exception("Style '" + xmlAttribute.Value + "' is not found.");
     }
     ruleDesc.style = styles[xmlAttribute.Value];
     var flag3 = xmlAttribute2 != null;
     if (flag3)
     {
         ruleDesc.options = (RegexOptions) Enum.Parse(typeof (RegexOptions), xmlAttribute2.Value);
     }
     return ruleDesc;
 }