DeclarationCondition
using System.IO;
namespace AngleSharp.Dom.Css
{
internal sealed class DeclarationCondition : CssNode, IConditionFunction, ICssNode, IStyleFormattable
{
private readonly CssProperty _property;
private readonly CssValue _value;
public DeclarationCondition(CssProperty property, CssValue value)
{
_property = property;
_value = value;
}
public bool Check()
{
if (!(_property is CssUnknownProperty))
return _property.TrySetValue(_value);
return false;
}
public override void ToCss(TextWriter writer, IStyleFormatter formatter)
{
writer.Write("(");
writer.Write(formatter.Declaration(_property.Name, _value.CssText, _property.IsImportant));
writer.Write(")");
}
}
}