CssOutlineProperty
sealed class CssOutlineProperty : CssShorthandProperty, ICssOutlineProperty, ICssProperty, ICssOutlineColorProperty, ICssOutlineStyleProperty, ICssOutlineWidthProperty
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;
namespace AngleSharp.Dom.Css
{
internal sealed class CssOutlineProperty : CssShorthandProperty, ICssOutlineProperty, ICssProperty, ICssOutlineColorProperty, ICssOutlineStyleProperty, ICssOutlineWidthProperty
{
internal static readonly IValueConverter<Tuple<Length, LineStyle, Color?>> Converter = Converters.WithAny(CssOutlineWidthProperty.Converter.Option(CssOutlineWidthProperty.Default), CssOutlineStyleProperty.Converter.Option(CssOutlineStyleProperty.Default), CssOutlineColorProperty.Converter.Option(CssOutlineColorProperty.Default));
private readonly CssOutlineStyleProperty _style;
private readonly CssOutlineWidthProperty _width;
private readonly CssOutlineColorProperty _color;
public LineStyle Style => _style.Style;
public Length Width => _width.Width;
public Color Color => _color.Color;
public bool IsInverted => _color.IsInverted;
internal CssOutlineProperty(CssStyleDeclaration rule)
: base(PropertyNames.Outline, rule, PropertyFlags.Animatable)
{
_style = Get<CssOutlineStyleProperty>();
_width = Get<CssOutlineWidthProperty>();
_color = Get<CssOutlineColorProperty>();
}
protected override bool IsValid(ICssValue value)
{
return Converter.TryConvert(value, delegate(Tuple<Length, LineStyle, Color?> m) {
_width.SetWidth(m.Item1);
_style.SetStyle(m.Item2);
_color.SetColor(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(),
_color.SerializeValue(),
_style.SerializeValue()
});
}
}
}