SharpVectors.Dom.Css.CssPrimitiveValue.Create C# (CSharp) 메소드

Create() 정적인 개인적인 메소드

static private Create ( Match match, bool readOnly ) : CssPrimitiveValue
match System.Text.RegularExpressions.Match
readOnly bool
리턴 CssPrimitiveValue
        internal static CssPrimitiveValue Create(Match match, bool readOnly)
        {
            if(match.Groups["length"].Success)
            {
                return new CssPrimitiveLengthValue(match.Groups["lengthNumber"].Value, match.Groups["lengthUnit"].Value, readOnly);
            }
            else if(match.Groups["angle"].Success)
            {
                return new CssPrimitiveAngleValue(match.Groups["angleNumber"].Value, match.Groups["angleUnit"].Value, readOnly);
            }
            else if(match.Groups["funcname"].Success && match.Groups["funcname"].Value == "rgb")
            {
                return new CssPrimitiveRgbValue(match.Groups["func"].Value, readOnly);
            }
            else if(match.Groups["colorIdent"].Success && CssPrimitiveRgbValue.IsColorName(match.Groups["colorIdent"].Value))
            {
                return new CssPrimitiveRgbValue(match.Groups["colorIdent"].Value, readOnly);
            }
            else
            {
                return new CssPrimitiveValue(match, readOnly);
            }
        }

Usage Example

예제 #1
0
        /// <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));
                }
            }
        }
All Usage Examples Of SharpVectors.Dom.Css.CssPrimitiveValue::Create