AngleSharp by Florian Rappl

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

.NET API 1,229,312 bytes

 CssShorthandProperty

Base class for all shorthand properties
using AngleSharp.Css; using System.Collections.Generic; using System.Linq; namespace AngleSharp.Dom.Css { internal abstract class CssShorthandProperty : CssProperty { private readonly CssProperty[] _properties; public CssProperty[] Properties => _properties; public CssShorthandProperty(string name, CssStyleDeclaration rule, PropertyFlags flags = PropertyFlags.None) : base(name, rule, flags | PropertyFlags.Shorthand) { _properties = Factory.Properties.CreateLonghandsFor(name, rule).ToArray(); } protected sealed override object GetDefault(IElement element) { return null; } protected sealed override object Compute(IElement element) { return null; } protected TProperty Get<TProperty>() { return _properties.OfType<TProperty>().FirstOrDefault(); } protected static string SerializePeriodic(CssProperty t, CssProperty r, CssProperty b, CssProperty l) { string top = t.SerializeValue(); string right = r.SerializeValue(); string bottom = b.SerializeValue(); string left = l.SerializeValue(); return SerializePeriodic(top, right, bottom, left); } protected static string SerializePeriodic(ICssValue top, ICssValue right, ICssValue bottom, ICssValue left) { return SerializePeriodic(top.CssText, right.CssText, bottom.CssText, left.CssText); } protected static string SerializePeriodic(string top, string right, string bottom, string left) { if (left != right) return $"{top}""{right}""{bottom}""{left}"; if (bottom != top) return string.Format("{0} {1} {2}", new object[3] { top, right, bottom }); if (right != top) return string.Format("{0} {1}", new object[2] { top, right }); return top; } internal sealed override void Reset() { base.Reset(); CssProperty[] properties = _properties; foreach (CssProperty cssProperty in properties) { cssProperty.Reset(); } } internal sealed override string SerializeValue() { return SerializeValue(_properties); } internal abstract string SerializeValue(IEnumerable<CssProperty> properties); } }