CssListStyleProperty
sealed class CssListStyleProperty : CssShorthandProperty, ICssListStyleProperty, ICssProperty, ICssListStyleImageProperty, ICssListStylePositionProperty, ICssListStyleTypeProperty
More information available at
https://developer.mozilla.org/en-US/docs/Web/CSS/list-style
using AngleSharp.Css;
using AngleSharp.Css.Values;
using AngleSharp.Extensions;
using System;
using System.Collections.Generic;
namespace AngleSharp.Dom.Css
{
internal sealed class CssListStyleProperty : CssShorthandProperty, ICssListStyleProperty, ICssProperty, ICssListStyleImageProperty, ICssListStylePositionProperty, ICssListStyleTypeProperty
{
internal static readonly IValueConverter<Tuple<ListStyle, ListPosition, IImageSource>> Converter = Converters.WithAny(CssListStyleTypeProperty.Converter.Option(CssListStyleTypeProperty.Default), CssListStylePositionProperty.Converter.Option(CssListStylePositionProperty.Default), CssListStyleImageProperty.Converter.Option(CssListStyleImageProperty.Default));
private readonly CssListStyleTypeProperty _type;
private readonly CssListStyleImageProperty _image;
private readonly CssListStylePositionProperty _position;
public ListStyle Style => _type.Style;
public IImageSource Image => _image.Image;
public ListPosition Position => _position.Position;
internal CssListStyleProperty(CssStyleDeclaration rule)
: base(PropertyNames.ListStyle, rule, PropertyFlags.Inherited)
{
_type = Get<CssListStyleTypeProperty>();
_image = Get<CssListStyleImageProperty>();
_position = Get<CssListStylePositionProperty>();
}
protected override bool IsValid(ICssValue value)
{
return Converter.TryConvert(value, delegate(Tuple<ListStyle, ListPosition, IImageSource> m) {
_type.SetStyle(m.Item1);
_position.SetPosition(m.Item2);
_image.SetImage(m.Item3);
});
}
internal override string SerializeValue(IEnumerable<CssProperty> properties)
{
if (!IsComplete(properties))
return string.Empty;
return string.Format("{0} {1} {2}", new object[3] {
_type.SerializeValue(),
_image.SerializeValue(),
_position.SerializeValue()
});
}
}
}