CssRule
Represents a CSS rule.
using AngleSharp.Parser.Css;
namespace AngleSharp.Dom.Css
{
internal abstract class CssRule : ICssRule
{
private readonly CssRuleType _type;
private ICssStyleSheet _ownerSheet;
private ICssRule _parentRule;
public string CssText {
get {
return ToCss();
}
set {
CssRule cssRule = CssParser.ParseRule(value, null);
if (cssRule == null)
throw new DomException(DomError.Syntax);
if (cssRule.Type != _type)
throw new DomException(DomError.InvalidModification);
ReplaceWith(cssRule);
}
}
public ICssRule Parent {
get {
return _parentRule;
}
internal set {
_parentRule = value;
}
}
public ICssStyleSheet Owner {
get {
return _ownerSheet;
}
internal set {
_ownerSheet = value;
}
}
public CssRuleType Type => _type;
internal CssRule(CssRuleType type)
{
_type = type;
}
protected abstract void ReplaceWith(ICssRule rule);
protected abstract string ToCss();
}
}