AngleSharp by AngleSharp

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

.NET API 1,204,224 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.HasFlag(PropertyFlags.Inherited) || !IsInitial) { if (_value != null) return _value.CssText.Is(Keywords.Inherit); return false; } return true; } } public bool IsAnimatable => _flags.HasFlag(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.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; } } 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)); } } }