CssOutlineProperty
More information available:
https://developer.mozilla.org/en-US/docs/Web/CSS/outline
using AngleSharp.Css;
using AngleSharp.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
namespace AngleSharp.Dom.Css
{
internal sealed class CssOutlineProperty : CssShorthandProperty
{
private static readonly IValueConverter<Tuple<ICssValue, ICssValue, ICssValue>> Converter = Converters.WithAny(Converters.LineWidthConverter.Val().Option(), Converters.LineStyleConverter.Val().Option(), Converters.InvertedColorConverter.Val().Option());
internal CssOutlineProperty(CssStyleDeclaration rule)
: base(PropertyNames.Outline, rule, PropertyFlags.Animatable)
{
}
protected override bool IsValid(ICssValue value)
{
return Converter.TryConvert(value, delegate(Tuple<ICssValue, ICssValue, ICssValue> m) {
Get<CssOutlineWidthProperty>().TrySetValue(m.Item1);
Get<CssOutlineStyleProperty>().TrySetValue(m.Item2);
Get<CssOutlineColorProperty>().TrySetValue(m.Item3);
});
}
internal override string SerializeValue(IEnumerable<CssProperty> properties)
{
CssOutlineWidthProperty cssOutlineWidthProperty = properties.OfType<CssOutlineWidthProperty>().FirstOrDefault();
CssOutlineStyleProperty cssOutlineStyleProperty = properties.OfType<CssOutlineStyleProperty>().FirstOrDefault();
CssOutlineColorProperty cssOutlineColorProperty = properties.OfType<CssOutlineColorProperty>().FirstOrDefault();
if (cssOutlineWidthProperty == null || cssOutlineStyleProperty == null || cssOutlineColorProperty == null)
return string.Empty;
List<string> list = new List<string>();
if (cssOutlineWidthProperty.HasValue)
list.Add(cssOutlineWidthProperty.SerializeValue());
if (cssOutlineColorProperty.HasValue)
list.Add(cssOutlineColorProperty.SerializeValue());
if (cssOutlineStyleProperty.HasValue)
list.Add(cssOutlineStyleProperty.SerializeValue());
return string.Join(" ", list);
}
}
}