public static RuleSet Parse(string str) { string s = str.Trim().TrimEnd('}'); string[] splitted = s.Split(new char[] { '{' }); if (splitted.Length != 2) throw new InvalidStructureException(String.Format("Ruleset must contains selector and declaration which quoted by {}, the exception string is {0}", str)); RuleSet result = new RuleSet(); foreach (var each in splitted[0].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)) { result.Selectors.Add(Selector.Parse(each)); } result.Declaration = Declaration.Parse(splitted[1]); return result; }