static IDistance GetMode(CSSValue value, String minIdentifier, String maxIdentifier) { var calc = value.ToDistance(); if (calc == null) { var ident = value.ToIdentifier(); if (ident != null) { if (ident.Equals(minIdentifier, StringComparison.OrdinalIgnoreCase)) { calc = Percent.Zero; } else if (ident.Equals(maxIdentifier, StringComparison.OrdinalIgnoreCase)) { calc = Percent.Hundred; } else if (ident.Equals(Keywords.Center, StringComparison.OrdinalIgnoreCase)) { calc = Percent.Fifty; } } } return(calc); }
Boolean SetSingle(CSSValue value) { var calc = value.ToDistance(); if (calc != null) { _x = calc; _y = calc; return(true); } var ident = value.ToIdentifier(); if (ident != null) { if (ident.Equals(Keywords.Left, StringComparison.OrdinalIgnoreCase)) { _x = Percent.Zero; _y = Percent.Fifty; _z = Percent.Zero; return(true); } else if (ident.Equals(Keywords.Center, StringComparison.OrdinalIgnoreCase)) { _x = Percent.Fifty; _y = Percent.Fifty; _z = Percent.Zero; return(true); } else if (ident.Equals(Keywords.Right, StringComparison.OrdinalIgnoreCase)) { _x = Percent.Hundred; _y = Percent.Fifty; _z = Percent.Zero; return(true); } else if (ident.Equals(Keywords.Top, StringComparison.OrdinalIgnoreCase)) { _x = Percent.Fifty; _y = Percent.Zero; _z = Percent.Zero; return(true); } else if (ident.Equals(Keywords.Bottom, StringComparison.OrdinalIgnoreCase)) { _x = Percent.Fifty; _y = Percent.Hundred; _z = Percent.Zero; return(true); } } return(false); }
/// <summary> /// Determines if the given value represents a valid state of this property. /// </summary> /// <param name="value">The state that should be used.</param> /// <returns>True if the state is valid, otherwise false.</returns> protected override Boolean IsValid(CSSValue value) { if (value.Is(Keywords.None)) { _names.Clear(); } else if (value is CSSPrimitiveValue) { var name = value.ToIdentifier(); if (name == null) { return(false); } _names.Clear(); _names.Add(name); } else if (value is CSSValueList) { var names = value.AsList(ValueExtensions.ToIdentifier); if (names == null) { return(false); } _names.Clear(); _names.AddRange(names); } else { return(false); } return(true); }