CssBorderStyleProperty
Information can be found on MDN:
https://developer.mozilla.org/en-US/docs/Web/CSS/border-style
using AngleSharp.Css;
using AngleSharp.Extensions;
using System;
using System.Collections.Generic;
namespace AngleSharp.Dom.Css
{
internal sealed class CssBorderStyleProperty : CssShorthandProperty, ICssBorderStylesProperty, ICssProperty
{
internal static readonly IValueConverter<Tuple<ICssValue, ICssValue, ICssValue, ICssValue>> Converter = CssBorderPartStyleProperty.Converter.Val().Periodic();
private readonly CssBorderTopStyleProperty _top;
private readonly CssBorderRightStyleProperty _right;
private readonly CssBorderBottomStyleProperty _bottom;
private readonly CssBorderLeftStyleProperty _left;
public LineStyle Top => _top.Style;
public LineStyle Right => _right.Style;
public LineStyle Bottom => _bottom.Style;
public LineStyle Left => _left.Style;
internal CssBorderStyleProperty(CssStyleDeclaration rule)
: base(PropertyNames.BorderStyle, rule, PropertyFlags.None)
{
_top = Get<CssBorderTopStyleProperty>();
_right = Get<CssBorderRightStyleProperty>();
_bottom = Get<CssBorderBottomStyleProperty>();
_left = Get<CssBorderLeftStyleProperty>();
}
protected override bool IsValid(ICssValue value)
{
return Converter.TryConvert(value, delegate(Tuple<ICssValue, ICssValue, ICssValue, ICssValue> m) {
_top.TrySetValue(m.Item1);
_right.TrySetValue(m.Item2);
_bottom.TrySetValue(m.Item3);
_left.TrySetValue(m.Item4);
});
}
internal override string SerializeValue(IEnumerable<CssProperty> properties)
{
if (!IsComplete(properties))
return string.Empty;
return CssShorthandProperty.SerializePeriodic(_top, _right, _bottom, _left);
}
}
}