AngleSharp by AngleSharp

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

.NET API 1,214,976 bytes

 ContinuousValueConverter

using AngleSharp.Dom.Css; using AngleSharp.Extensions; using AngleSharp.Parser.Css; using System.Collections.Generic; using System.Linq; namespace AngleSharp.Css.ValueConverters { internal sealed class ContinuousValueConverter : IValueConverter { private sealed class OptionsValue : IPropertyValue { private readonly IPropertyValue[] _options; private readonly CssValue _value; public string CssText => string.Join(" ", from m in _options where !string.IsNullOrEmpty(m.CssText) select m.CssText); public CssValue Original => _value; public OptionsValue(IPropertyValue[] options, IEnumerable<CssToken> tokens) { _options = options; _value = new CssValue(tokens); } public CssValue ExtractFor(string name) { List<CssToken> list = new List<CssToken>(); IPropertyValue[] options = _options; for (int i = 0; i < options.Length; i++) { CssValue cssValue = options[i].ExtractFor(name); if (cssValue != null) { if (list.Count > 0) list.Add(CssToken.Whitespace); list.AddRange(cssValue); } } return new CssValue(list); } } private readonly IValueConverter _converter; public ContinuousValueConverter(IValueConverter converter) { _converter = converter; } public IPropertyValue Convert(IEnumerable<CssToken> value) { List<CssToken> list = new List<CssToken>(value); List<IPropertyValue> list2 = new List<IPropertyValue>(); if (list.Count > 0) { while (list.Count != 0) { IPropertyValue propertyValue = _converter.VaryStart(list); if (propertyValue == null) return null; list2.Add(propertyValue); } return new OptionsValue(list2.ToArray(), value); } return null; } public IPropertyValue Construct(CssProperty[] properties) { return properties.Guard<OptionsValue>(); } } }