/// <summary> /// Detects what kind of value cssText contains and returns an instance of the correct CssValue class /// </summary> /// <param name="cssText">The text to parse for a CSS value</param> /// <param name="readOnly">Specifies if this instance is read-only</param> /// <returns>The correct type of CSS value</returns> static public CssValue GetCssValue(string cssText, bool readOnly) { if (cssText == "inherit") { // inherit return(new CssValue(CssValueType.Inherit, cssText, readOnly)); } else { Match match = reCssPrimitiveValue.Match(cssText); if (match.Success) { // single primitive value return(CssPrimitiveValue.Create(match, readOnly)); } match = reCssValueList.Match(cssText); if (match.Success) { // list of primitive values throw new NotImplementedException("Value lists not implemented"); } else { // custom value return(new CssValue(CssValueType.Custom, cssText, readOnly)); } } }
/// <summary> /// Detects what kind of value cssText contains and returns an instance of the correct CssValue class /// </summary> /// <param name="cssText">The text to parse for a CSS value</param> /// <param name="readOnly">Specifies if this instance is read-only</param> /// <returns>The correct type of CSS value</returns> public static CssValue GetCssValue(string cssText, bool readOnly) { if (string.Equals(cssText, "inherit", StringComparison.OrdinalIgnoreCase)) { // inherit return(new CssValue(CssValueType.Inherit, cssText, readOnly)); } Match match = _reCssPrimitiveValue.Match(cssText); if (match.Success) { // single primitive value return(CssPrimitiveValue.Create(match, readOnly)); } match = _reCssValueList.Match(cssText); if (match.Success) { // list of primitive values throw new NotImplementedException("Value lists not implemented"); } // custom value return(new CssValue(CssValueType.Custom, cssText, readOnly)); }