CssColumnRuleProperty
More information available at:
https://developer.mozilla.org/en-US/docs/Web/CSS/column-rule
using AngleSharp.Css;
using AngleSharp.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
namespace AngleSharp.Dom.Css
{
internal sealed class CssColumnRuleProperty : CssShorthandProperty
{
private static readonly IValueConverter<Tuple<CssValue, CssValue, CssValue>> Converter = Converters.WithAny(Converters.ColorConverter.Val().Option(), Converters.LineWidthConverter.Val().Option(), Converters.LineStyleConverter.Val().Option());
internal CssColumnRuleProperty(CssStyleDeclaration rule)
: base(PropertyNames.ColumnRule, rule, PropertyFlags.Animatable)
{
}
protected override bool IsValid(CssValue value)
{
return Converter.TryConvert(value, delegate(Tuple<CssValue, CssValue, CssValue> m) {
Get<CssColumnRuleColorProperty>().TrySetValue(m.Item1);
Get<CssColumnRuleWidthProperty>().TrySetValue(m.Item2);
Get<CssColumnRuleStyleProperty>().TrySetValue(m.Item3);
});
}
internal override string SerializeValue(IEnumerable<CssProperty> properties)
{
CssColumnRuleWidthProperty cssColumnRuleWidthProperty = properties.OfType<CssColumnRuleWidthProperty>().FirstOrDefault();
CssColumnRuleStyleProperty cssColumnRuleStyleProperty = properties.OfType<CssColumnRuleStyleProperty>().FirstOrDefault();
CssColumnRuleColorProperty cssColumnRuleColorProperty = properties.OfType<CssColumnRuleColorProperty>().FirstOrDefault();
if (cssColumnRuleWidthProperty == null || cssColumnRuleStyleProperty == null || cssColumnRuleColorProperty == null)
return string.Empty;
return string.Format("{0} {1} {2}", new object[3] {
cssColumnRuleWidthProperty.SerializeValue(),
cssColumnRuleStyleProperty.SerializeValue(),
cssColumnRuleColorProperty.SerializeValue()
});
}
}
}