CssBorderImageProperty
sealed class CssBorderImageProperty : CssShorthandProperty, ICssBorderImageProperty, ICssProperty, ICssBorderImageWidthProperty, ICssBorderImageSourceProperty, ICssBorderImageSliceProperty, ICssBorderImageRepeatProperty, ICssBorderImageOutsetProperty
More information available at:
https://developer.mozilla.org/en-US/docs/Web/CSS/border-image
using AngleSharp.Css;
using AngleSharp.Css.Values;
using AngleSharp.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
namespace AngleSharp.Dom.Css
{
internal sealed class CssBorderImageProperty : CssShorthandProperty, ICssBorderImageProperty, ICssProperty, ICssBorderImageWidthProperty, ICssBorderImageSourceProperty, ICssBorderImageSliceProperty, ICssBorderImageRepeatProperty, ICssBorderImageOutsetProperty
{
internal static readonly IValueConverter<Tuple<ICssValue, Tuple<ICssValue, ICssValue, ICssValue>, ICssValue>> Converter = Converters.WithAny(CssBorderImageSourceProperty.Converter.Val().Option(), Converters.WithOrder(CssBorderImageSliceProperty.Converter.Val().Option(), CssBorderImageWidthProperty.Converter.Val().StartsWithDelimiter().Option(), CssBorderImageOutsetProperty.Converter.Val().StartsWithDelimiter().Option()), CssBorderImageRepeatProperty.Converter.Val().Option());
private readonly CssBorderImageOutsetProperty _outset;
private readonly CssBorderImageRepeatProperty _repeat;
private readonly CssBorderImageSliceProperty _slice;
private readonly CssBorderImageWidthProperty _width;
private readonly CssBorderImageSourceProperty _source;
public Length OutsetBottom => _outset.OutsetBottom;
public Length OutsetLeft => _outset.OutsetLeft;
public Length OutsetRight => _outset.OutsetRight;
public Length OutsetTop => _outset.OutsetTop;
public BorderRepeat Horizontal => _repeat.Horizontal;
public BorderRepeat Vertical => _repeat.Vertical;
public bool IsFilled => _slice.IsFilled;
public Length SliceBottom => _slice.SliceBottom;
public Length SliceRight => _slice.SliceRight;
public Length SliceTop => _slice.SliceTop;
public Length SliceLeft => _slice.SliceLeft;
public IImageSource Image => _source.Image;
public Length WidthTop => _width.WidthTop;
public Length WidthBottom => _width.WidthBottom;
public Length WidthLeft => _width.WidthLeft;
public Length WidthRight => _width.WidthRight;
internal CssBorderImageProperty(CssStyleDeclaration rule)
: base(PropertyNames.BorderImage, rule, PropertyFlags.None)
{
_outset = Get<CssBorderImageOutsetProperty>();
_repeat = Get<CssBorderImageRepeatProperty>();
_slice = Get<CssBorderImageSliceProperty>();
_source = Get<CssBorderImageSourceProperty>();
_width = Get<CssBorderImageWidthProperty>();
}
protected override bool IsValid(ICssValue value)
{
return Converter.TryConvert(value, delegate(Tuple<ICssValue, Tuple<ICssValue, ICssValue, ICssValue>, ICssValue> m) {
_source.TrySetValue(m.Item1);
_slice.TrySetValue(m.Item2.Item1);
_width.TrySetValue(m.Item2.Item2);
_outset.TrySetValue(m.Item2.Item3);
_repeat.TrySetValue(m.Item3);
});
}
internal override string SerializeValue(IEnumerable<CssProperty> properties)
{
if (!properties.Contains(_source))
return string.Empty;
List<string> list = new List<string>();
list.Add(_source.SerializeValue());
if (_slice.HasValue && properties.Contains(_slice))
list.Add(_slice.SerializeValue());
bool flag = _width.HasValue && properties.Contains(_width);
bool flag2 = _outset.HasValue && properties.Contains(_outset);
if (flag | flag2) {
list.Add("/");
if (flag)
list.Add(_width.SerializeValue());
if (flag2) {
list.Add("/");
list.Add(_outset.SerializeValue());
}
}
if (_repeat.HasValue && properties.Contains(_repeat))
list.Add(_repeat.SerializeValue());
return string.Format(" ", new object[1] {
list
});
}
}
}