CssPaddingProperty
sealed class CssPaddingProperty : CssShorthandProperty, ICssPaddingProperty, ICssProperty, ICssPaddingBottomProperty, ICssPaddingRightProperty, ICssPaddingTopProperty, ICssPaddingLeftProperty
Information can be found on MDN:
https://developer.mozilla.org/en-US/docs/Web/CSS/padding
using AngleSharp.Css;
using AngleSharp.Extensions;
using System;
using System.Collections.Generic;
namespace AngleSharp.Dom.Css
{
internal sealed class CssPaddingProperty : CssShorthandProperty, ICssPaddingProperty, ICssProperty, ICssPaddingBottomProperty, ICssPaddingRightProperty, ICssPaddingTopProperty, ICssPaddingLeftProperty
{
internal static readonly IValueConverter<Tuple<ICssValue, ICssValue, ICssValue, ICssValue>> Converter = CssPaddingPartProperty.Converter.Val().Periodic();
private readonly CssPaddingTopProperty _top;
private readonly CssPaddingRightProperty _right;
private readonly CssPaddingBottomProperty _bottom;
private readonly CssPaddingLeftProperty _left;
public Length Top => _top.Top;
public Length Right => _right.Right;
public Length Bottom => _bottom.Bottom;
public Length Left => _left.Left;
internal CssPaddingProperty(CssStyleDeclaration rule)
: base(PropertyNames.Padding, rule, PropertyFlags.None)
{
_top = Get<CssPaddingTopProperty>();
_right = Get<CssPaddingRightProperty>();
_bottom = Get<CssPaddingBottomProperty>();
_left = Get<CssPaddingLeftProperty>();
}
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);
}
}
}