CssBackgroundAttachmentProperty
sealed class CssBackgroundAttachmentProperty : CssProperty, ICssBackgroundAttachmentProperty, ICssProperty
More information available at:
https://developer.mozilla.org/en-US/docs/Web/CSS/background-attachment
using AngleSharp.Css;
using AngleSharp.Extensions;
using System.Collections.Generic;
namespace AngleSharp.Dom.Css
{
internal sealed class CssBackgroundAttachmentProperty : CssProperty, ICssBackgroundAttachmentProperty, ICssProperty
{
internal static readonly BackgroundAttachment Default = BackgroundAttachment.Scroll;
internal static readonly IValueConverter<BackgroundAttachment> SingleConverter = Map.BackgroundAttachments.ToConverter();
internal static readonly IValueConverter<BackgroundAttachment[]> Converter = SingleConverter.FromList();
private readonly List<BackgroundAttachment> _attachments;
public IEnumerable<BackgroundAttachment> Attachments => _attachments;
internal CssBackgroundAttachmentProperty(CssStyleDeclaration rule)
: base(PropertyNames.BackgroundAttachment, rule, PropertyFlags.None)
{
_attachments = new List<BackgroundAttachment>();
Reset();
}
public void SetAttachments(IEnumerable<BackgroundAttachment> attachments)
{
_attachments.Clear();
_attachments.AddRange(attachments);
}
internal override void Reset()
{
_attachments.Clear();
_attachments.Add(Default);
}
protected override bool IsValid(ICssValue value)
{
return Converter.TryConvert(value, SetAttachments);
}
}
}