AngleSharp by AngleSharp

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

.NET API 1,230,336 bytes

 CssProperty

Fore more information about CSS properties see: http://www.w3.org/TR/CSS21/propidx.html.
using AngleSharp.Css; using AngleSharp.Extensions; using System.IO; namespace AngleSharp.Dom.Css { internal abstract class CssProperty : CssNode, ICssProperty, ICssNode, IStyleFormattable { private readonly PropertyFlags _flags; private readonly string _name; private bool _important; private IPropertyValue _value; public string Value { get { if (_value == null) return Keywords.Initial; return _value.CssText; } } public bool IsInherited { get { if ((_flags & PropertyFlags.Inherited) != PropertyFlags.Inherited || !IsInitial) { if (_value != null) return _value.CssText.Is(Keywords.Inherit); return false; } return true; } } public bool IsAnimatable => (_flags & PropertyFlags.Animatable) == PropertyFlags.Animatable; public bool IsInitial { get { if (_value != null) return _value.CssText.Is(Keywords.Initial); return true; } } public string Name => _name; public bool IsImportant { get { return _important; } set { _important = value; } } public string CssText => this.ToCss(); internal bool HasValue => _value != null; internal bool CanBeHashless => (_flags & PropertyFlags.Hashless) == PropertyFlags.Hashless; internal bool CanBeUnitless => (_flags & PropertyFlags.Unitless) == PropertyFlags.Unitless; internal bool CanBeInherited => (_flags & PropertyFlags.Inherited) == PropertyFlags.Inherited; internal bool IsShorthand => (_flags & PropertyFlags.Shorthand) == PropertyFlags.Shorthand; internal abstract IValueConverter Converter { get; } internal IPropertyValue DeclaredValue { get { return _value; } set { _value = value; } } 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 override void ToCss(TextWriter writer, IStyleFormatter formatter) { writer.Write(formatter.Declaration(Name, Value, IsImportant)); } } }