public ColorSet(string name, ColorSetType type, ColorSetCollection colors, string attrs = "") { this.Name = name; this.type = type; this.attrs = attrs; this.Collection = colors; this.ParseAttributes(); //this.Collection.AddColorSet(this); }
public ColorSet(string colorSetDescription, ColorSetCollection colors) { string[] masks = new string[] { //@"^(?<name>\w.*)\s*=\s*(?<type>\w+)$", @"^\s*(?<name>([A-Z]|[a-z])([A-Z]|[a-z]|[0-9])*)\s*=\s*(?<type>\w+)\((?<attrs>(.|\n)*)\)\s*$" }; Match m = null; foreach (var mask in masks) { m = Regex.Match(colorSetDescription, mask); if (m.Success) { break; } } if (m == null || !m.Success || !ColorSet.Types.ContainsKey(m.Groups["type"].Value)) { throw new InvalidColorSetAttributesException("NewColorSet()", colorSetDescription); } this.Name = m.Groups["name"].Value.Trim(); this.type = ColorSet.Types[m.Groups["type"].Value]; this.attrs = m.Groups["attrs"].Value; this.Collection = colors; this.ParseAttributes(); //this.Collection.AddColorSet(this); }