SharpVectors.Dom.Css.CssStyleDeclaration.parseString C# (CSharp) Method

parseString() private method

private parseString ( string cssText ) : string
cssText string
return string
        private string parseString(string cssText)
        {
            bool startedWithABracket = false;

            cssText = cssText.Trim();
            if(cssText.StartsWith("{"))
            {
                cssText = cssText.Substring(1).Trim();
                startedWithABracket = true;
            }

            Match match = styleRegex.Match(cssText);
            while(match.Success)
            {
                string name = match.Groups["name"].Value;
                string value = match.Groups["value"].Value;
                if(_parentRule != null)
                {
                    value = ((CssRule)_parentRule).DeReplaceStrings(value);
                }
                string prio = match.Groups["priority"].Value;

                SharpCssStyle style = new SharpCssStyle(name, value, prio, _origin);

                bool addStyle = false;
                if(styles.ContainsKey(name))
                {
                    string existingPrio = ((SharpCssStyle)styles[name]).Priority;

                    if(existingPrio != "important" ||
                        prio == "important")
                    {
                        styles.Remove(name);
                        addStyle = true;
                    }
                }
                else
                {
                    addStyle = true;

                }

                if(addStyle)
                {
                    styles.Add(name, style);
                }

                cssText = cssText.Substring(match.Length).Trim();
                match = styleRegex.Match(cssText);
            }

            cssText = cssText.Trim();
            if(cssText.StartsWith("}"))
            {
                cssText = cssText.Substring(1);
            }
            else if(startedWithABracket)
            {
                throw new DomException(DomExceptionType.SyntaxErr, "Style declaration ending bracket missing");
            }
            return cssText;
        }