CssColumnRuleProperty
sealed class CssColumnRuleProperty : CssShorthandProperty, ICssColumnRuleProperty, ICssProperty, ICssColumnRuleColorProperty, ICssColumnRuleStyleProperty, ICssColumnRuleWidthProperty
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;
namespace AngleSharp.Dom.Css
{
internal sealed class CssColumnRuleProperty : CssShorthandProperty, ICssColumnRuleProperty, ICssProperty, ICssColumnRuleColorProperty, ICssColumnRuleStyleProperty, ICssColumnRuleWidthProperty
{
internal static readonly IValueConverter<Tuple<Color, Length, LineStyle>> Converter = Converters.WithAny(CssColumnRuleColorProperty.Converter.Option(CssColumnRuleColorProperty.Default), CssColumnRuleWidthProperty.Converter.Option(CssColumnRuleWidthProperty.Default), CssColumnRuleStyleProperty.Converter.Option(CssColumnRuleStyleProperty.Default));
private readonly CssColumnRuleColorProperty _color;
private readonly CssColumnRuleStyleProperty _style;
private readonly CssColumnRuleWidthProperty _width;
public Color Color => _color.Color;
public LineStyle Style => _style.Style;
public Length Width => _width.Width;
internal CssColumnRuleProperty(CssStyleDeclaration rule)
: base(PropertyNames.ColumnRule, rule, PropertyFlags.Animatable)
{
_color = Get<CssColumnRuleColorProperty>();
_style = Get<CssColumnRuleStyleProperty>();
_width = Get<CssColumnRuleWidthProperty>();
}
protected override bool IsValid(ICssValue value)
{
return Converter.TryConvert(value, delegate(Tuple<Color, Length, LineStyle> m) {
_color.SetColor(m.Item1);
_width.SetWidth(m.Item2);
_style.SetStyle(m.Item3);
});
}
internal override string SerializeValue(IEnumerable<CssProperty> properties)
{
if (!IsComplete(properties))
return string.Empty;
return string.Format("{0} {1} {2}", new object[3] {
_width.SerializeValue(),
_style.SerializeValue(),
_color.SerializeValue()
});
}
}
}