AngleSharp by Florian Rappl

<PackageReference Include="AngleSharp" Version="0.8.0" />

.NET API 1,171,968 bytes

 CssBackgroundRepeatProperty

More information available at: https://developer.mozilla.org/en-US/docs/Web/CSS/background-repeat
using AngleSharp.Css; using AngleSharp.Extensions; using System; using System.Collections.Generic; using System.Linq; namespace AngleSharp.Dom.Css { internal sealed class CssBackgroundRepeatProperty : CssProperty, ICssBackgroundRepeatProperty, ICssProperty { internal struct Repeat { public BackgroundRepeat Horizontal; public BackgroundRepeat Vertical; } internal static readonly Repeat Default; internal static readonly IValueConverter<Repeat> SingleConverter; internal static readonly IValueConverter<Repeat[]> Converter; private readonly List<Repeat> _repeats; public IEnumerable<BackgroundRepeat> HorizontalRepeats => from m in _repeats select m.Horizontal; public IEnumerable<BackgroundRepeat> VerticalRepeats => from m in _repeats select m.Vertical; static CssBackgroundRepeatProperty() { Repeat repeat = new Repeat { Horizontal = BackgroundRepeat.Repeat, Vertical = BackgroundRepeat.Repeat }; Default = repeat; IValueConverter<Repeat> primary = Map.BackgroundRepeats.ToConverter().To(delegate(BackgroundRepeat m) { Repeat result2 = default(Repeat); result2.Horizontal = m; result2.Vertical = m; return result2; }); string repeatX = Keywords.RepeatX; repeat = new Repeat { Horizontal = BackgroundRepeat.Repeat, Vertical = BackgroundRepeat.NoRepeat }; IValueConverter<Repeat> primary2 = primary.Or(repeatX, repeat); string repeatY = Keywords.RepeatY; repeat = new Repeat { Horizontal = BackgroundRepeat.NoRepeat, Vertical = BackgroundRepeat.Repeat }; SingleConverter = primary2.Or(repeatY, repeat).Or(Converters.WithOrder(Map.BackgroundRepeats.ToConverter().Required(), Map.BackgroundRepeats.ToConverter().Required()).To(delegate(Tuple<BackgroundRepeat, BackgroundRepeat> m) { Repeat result = default(Repeat); result.Horizontal = m.Item1; result.Vertical = m.Item2; return result; })); Converter = SingleConverter.FromList(); } internal CssBackgroundRepeatProperty(CssStyleDeclaration rule) : base(PropertyNames.BackgroundRepeat, rule, PropertyFlags.None) { _repeats = new List<Repeat>(); Reset(); } private void SetRepeats(IEnumerable<Repeat> repeats) { _repeats.Clear(); _repeats.AddRange(repeats); } internal override void Reset() { _repeats.Clear(); _repeats.Add(Default); } protected override bool IsValid(ICssValue value) { return Converter.TryConvert(value, SetRepeats); } } }