Class CssSimpleBlock
A simple block: content between matching (), [] or {}.
public sealed record CssSimpleBlock : CssComponentValue, IEquatable<CssComponentValue>, IEquatable<CssSimpleBlock>
- Inheritance
-
CssSimpleBlock
- Implements
- Inherited Members
Examples
// CSS Syntax 3 tokens, and component values: tokens, functions and simple blocks.
IReadOnlyList<CssToken> tokens = CssTokenizer.Tokenize("rgb(255 0 0 / 50%) 12px");
CssToken first = tokens[0];
bool isFunction = first.Kind == CssTokenKind.Function; // "rgb(" at line 1, column 1
IReadOnlyList<CssComponentValue> values = CssComponentValue.ParseList("calc(100% - 2px) [a] x");
var calc = (CssFunction)values[0];
var block = (CssSimpleBlock)values[2];
var word = (CssTokenValue)values[4];
string text = CssComponentValue.Serialize(values); // "calc(100% - 2px) [a] x"
Constructors
CssSimpleBlock(char, IReadOnlyList<CssComponentValue>)
A simple block: content between matching (), [] or {}.
public CssSimpleBlock(char OpenToken, IReadOnlyList<CssComponentValue> Content)
Parameters
OpenTokencharThe opening character:
(,[or{.ContentIReadOnlyList<CssComponentValue>The content, including whitespace.
Examples
// CSS Syntax 3 tokens, and component values: tokens, functions and simple blocks.
IReadOnlyList<CssToken> tokens = CssTokenizer.Tokenize("rgb(255 0 0 / 50%) 12px");
CssToken first = tokens[0];
bool isFunction = first.Kind == CssTokenKind.Function; // "rgb(" at line 1, column 1
IReadOnlyList<CssComponentValue> values = CssComponentValue.ParseList("calc(100% - 2px) [a] x");
var calc = (CssFunction)values[0];
var block = (CssSimpleBlock)values[2];
var word = (CssTokenValue)values[4];
string text = CssComponentValue.Serialize(values); // "calc(100% - 2px) [a] x"
Properties
CloseToken
Gets the closing character: ), ] or }.
public char CloseToken { get; }
Property Value
Column
Gets the 1-based column the value starts at, or 0 when unknown.
public override int Column { get; }
Property Value
Content
The content, including whitespace.
public IReadOnlyList<CssComponentValue> Content { get; init; }
Property Value
Line
Gets the 1-based line the value starts on, or 0 when unknown.
public override int Line { get; }
Property Value
OpenToken
The opening character: (, [ or {.
public char OpenToken { get; init; }
Property Value
Methods
Equals(CssSimpleBlock?)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(CssSimpleBlock? other)
Parameters
otherCssSimpleBlockAn object to compare with this object.
Returns
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.