/// <summary> /// This method fires the <see cref="SelectorReady"/> event and informs the caller /// in this way that a selector was found. /// </summary> /// <param name="so"></param> internal void OnSelectorReady(StyleObject so) { if (SelectorReady != null) { SelectorEventArgs args = new SelectorEventArgs(); args.Name = so.SelectorName; args.Type = so.SelectorType; args.Selector = so; SelectorReady(this, args); } }
/// <summary> /// Parses the given string and fires the selector event handler. /// </summary> /// <param name="main">Main class</param> /// <param name="source">Styles to parse</param> public void ParseStylesheet(CssParser main, string source) { if (source != null) { styles = new ArrayList(); Match match; if ((match = StyleSelectorRegex.Match(source, 0)).Success) { do { CaptureCollection selectors = match.Groups["selectors"].Captures; CaptureCollection cssText = match.Groups["csstext"].Captures; for (int i = 0; i < selectors.Count; i++) { so = new StyleObject(); GetStyleObject(cssText[i].ToString()); // create StyleObject from { content } String sn = selectors[i].ToString(); SelectorType st = GetSelectorType(selectors[i].ToString()); // // remove leading signs from names // switch (st) // { // case SelectorType.CLASS_SELECTOR: // case SelectorType.ID_SELECTOR: // sn = sn.Substring(1); // break; // } so.SelectorName = sn; so.SelectorType = st; styles.Add(so); main.OnSelectorReady(so); } match = match.NextMatch(); } while (match.Success); } } }