Class CssFunction
A function: its name and its arguments up to the closing parenthesis.
public sealed record CssFunction : CssComponentValue, IEquatable<CssComponentValue>, IEquatable<CssFunction>
- Inheritance
-
CssFunction
- 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
CssFunction(string, IReadOnlyList<CssComponentValue>)
A function: its name and its arguments up to the closing parenthesis.
public CssFunction(string Name, IReadOnlyList<CssComponentValue> Arguments)
Parameters
NamestringThe function name, as written (with escapes resolved).
ArgumentsIReadOnlyList<CssComponentValue>The arguments, including whitespace and commas.
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
Arguments
The arguments, including whitespace and commas.
public IReadOnlyList<CssComponentValue> Arguments { get; init; }
Property Value
Column
Gets the 1-based column the value starts at, or 0 when unknown.
public override int Column { get; }
Property Value
Line
Gets the 1-based line the value starts on, or 0 when unknown.
public override int Line { get; }
Property Value
Name
The function name, as written (with escapes resolved).
public string Name { get; init; }
Property Value
Methods
Equals(CssFunction?)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(CssFunction? other)
Parameters
otherCssFunctionAn 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.
NameIs(string)
Gets whether the function's name is lowercaseName, compared ASCII case-insensitively.
public bool NameIs(string lowercaseName)
Parameters
lowercaseNamestringThe name in lowercase.
Returns
- bool
True when the names match.