/// <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) { var num = value.ToInteger(); if (num.HasValue && num.Value >= 0) { _value = num.Value; 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) { var count = value.ToInteger(); if (count.HasValue) { _count = count.Value; } else if (value.Is(Keywords.Auto)) { _count = null; } else { return(false); } return(true); }
/// <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) { var number = value.ToInteger(); if (number != null) { _value = number.Value; } else if (value.Is(Keywords.Auto)) { _value = null; } else { return(false); } return(true); }
static CSSPrimitiveValue ToNumber(CSSValue value) { var number = value.ToInteger(); if (number != null) { var n = number.Value; if (n >= 0) { return((CSSPrimitiveValue)value); } } else if (value.Is(Keywords.Infinite)) { return(new CSSPrimitiveValue(Number.Infinite)); } return(null); }
/// <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) { FontWeight weight; if (_weights.TryGetValue(value, out weight)) { _weight = weight; return(true); } else { var val = value.ToInteger(); if (val.HasValue && val.Value >= 100 && val.Value <= 900) { _weight = new FontWeight { IsRelative = false, Value = val.Value }; return(true); } } return(false); }