public static void Add (SmokeyRule r) { if (cachedRules.ContainsKey (r.Id)) return; cachedRules [r.Id] = r; }
protected override void LoadRules (Category c) { // load xml file from smokey resources using (Stream ruleInfo = SmokeyRunner.Smokey.GetManifestResourceStream (c.Id + ".xml")) { using (XmlTextReader reader = new XmlTextReader (ruleInfo)) { reader.WhitespaceHandling = WhitespaceHandling.None; // we need to know all rule ids, names and descriptions while (reader.Read ()) { reader.ReadToFollowing ("Violation"); string ruleId = reader.GetAttribute ("checkID"); // id do { if (reader.EOF) break; reader.ReadToFollowing ("Translation"); } while (reader.GetAttribute ("lang") != "en"); if (reader.EOF) break; string ruleName = reader.GetAttribute ("typeName"); // name reader.ReadToFollowing ("Description"); string ruleDescription = reader.ReadElementContentAsString (); // description SmokeyRule rule = new SmokeyRule (ruleId, ruleName, ruleDescription); SmokeyRuleCache.Add (rule); base.AddRule (c, rule); } } } }
public static void Add(SmokeyRule r) { if (cachedRules.ContainsKey(r.Id)) { return; } cachedRules [r.Id] = r; }
protected override void LoadRules(Category c) { // load xml file from smokey resources using (Stream ruleInfo = SmokeyRunner.Smokey.GetManifestResourceStream(c.Id + ".xml")) { using (XmlTextReader reader = new XmlTextReader(ruleInfo)) { reader.WhitespaceHandling = WhitespaceHandling.None; // we need to know all rule ids, names and descriptions while (reader.Read()) { reader.ReadToFollowing("Violation"); string ruleId = reader.GetAttribute("checkID"); // id do { if (reader.EOF) { break; } reader.ReadToFollowing("Translation"); } while (reader.GetAttribute("lang") != "en"); if (reader.EOF) { break; } string ruleName = reader.GetAttribute("typeName"); // name reader.ReadToFollowing("Description"); string ruleDescription = reader.ReadElementContentAsString(); // description SmokeyRule rule = new SmokeyRule(ruleId, ruleName, ruleDescription); SmokeyRuleCache.Add(rule); base.AddRule(c, rule); } } } }