static List<string> GetDeclarationContext(CssFx.CssDeclaration Declaration, string Keyword) { List<string> Contexts = new List<string>(); if (Declaration.Property.IndexOf(Keyword, StringComparison.OrdinalIgnoreCase) > -1) { Contexts.Add(string.Format("Property-{0}", GetPosition(Declaration.Property, Keyword))); } foreach (CssFx.CssString Value in Declaration.Value.Values) { if (Value.Value.IndexOf(Keyword, StringComparison.OrdinalIgnoreCase) > -1) { Contexts.AddRange(GetValueContext(Value.Value, Keyword)); //Contexts.Add("Value"); } } return Contexts; }
static List<string> GetContext(CssFx.CssRuleSet Stmt, string Keyword) { List<string> Contexts = new List<string>(); foreach (CssFx.CssSelector Selector in Stmt.Selectors) { if (Selector.Value.IndexOf(Keyword, StringComparison.OrdinalIgnoreCase) > -1) { string SelectorValue = Selector.Value.Trim(); Contexts.AddRange(GetSelectorContext(SelectorValue, Keyword)); } } foreach (CssFx.CssDeclaration Declaration in Stmt.Declarations) { Contexts.AddRange(GetDeclarationContext(Declaration, Keyword)); } //Contexts.Add("RuleSet"); return Contexts; }
static List<string> GetContext(CssFx.CssAtRule Stmt, string Keyword) { List<string> Contexts = new List<string>(); bool Import = false; if(Stmt.Ident.Equals("import", StringComparison.OrdinalIgnoreCase)) { Import = true; } if (Stmt.Ident.IndexOf(Keyword, StringComparison.OrdinalIgnoreCase) > -1) { Contexts.Add(string.Format("Ident-Ident-{0}", GetPosition(Stmt.Ident, Keyword))); } if (Stmt.Value != null) { if (Stmt.Value.IndexOf(Keyword, StringComparison.OrdinalIgnoreCase) > -1) { if (Import) { Contexts.AddRange(GetImportIdentContext(Stmt.Value, Keyword)); } else if (Stmt.Ident.Equals("media", StringComparison.OrdinalIgnoreCase)) { Contexts.Add(string.Format("Ident-MediaValue-{0}", GetPosition(Stmt.Ident, Keyword))); } } } foreach (CssFx.ICssValue Value in Stmt.Block.Values) { try { CssFx.CssDeclaration Declaration = (CssFx.CssDeclaration)Value; Contexts.AddRange(GetDeclarationContext(Declaration, Keyword)); }catch{} } return Contexts; }