AngleSharp by Florian Rappl

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

.NET API 1,175,040 bytes

 CssProperty

Fore more information about CSS properties see: http://www.w3.org/TR/CSS21/propidx.html.
using AngleSharp.Css; namespace AngleSharp.Dom.Css { internal abstract class CssProperty : ICssProperty, IStyleFormattable { private readonly PropertyFlags _flags; private readonly string _name; private bool _important; private IPropertyValue _value; internal bool HasValue => _value != null; internal bool CanBeHashless => _flags.HasFlag(PropertyFlags.Hashless); internal bool CanBeUnitless => _flags.HasFlag(PropertyFlags.Unitless); internal bool CanBeInherited => _flags.HasFlag(PropertyFlags.Inherited); internal bool IsShorthand => _flags.HasFlag(PropertyFlags.Shorthand); internal abstract IValueConverter Converter { get; } internal IPropertyValue DeclaredValue { get { return _value; } set { _value = value; } } public string Value { get { if (_value == null) return Keywords.Initial; return _value.CssText; } } public bool IsInherited { get { if (!_flags.HasFlag(PropertyFlags.Inherited) || !IsInitial) { if (_value != null) return _value.CssText == Keywords.Inherit; return false; } return true; } } public bool IsAnimatable => _flags.HasFlag(PropertyFlags.Animatable); public bool IsInitial { get { if (_value != null) return _value.CssText == Keywords.Initial; return true; } } public string Name => _name; public bool IsImportant { get { return _important; } set { _important = value; } } public string CssText => ToCss(); internal CssProperty(string name, PropertyFlags flags = PropertyFlags.None) { _name = name; _flags = flags; } internal bool TrySetValue(CssValue newValue) { IPropertyValue propertyValue = Converter.Convert(newValue ?? CssValue.Initial); if (propertyValue != null) { _value = propertyValue; return true; } return false; } public string ToCss() { return ToCss(CssStyleFormatter.Instance); } public string ToCss(IStyleFormatter formatter) { return formatter.Declaration(Name, Value, IsImportant); } } }