Table of Contents

Class CssFunction

Namespace
Egami.Css
Assembly
Egami.Css.dll

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

Name string

The function name, as written (with escapes resolved).

Arguments IReadOnlyList<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

IReadOnlyList<CssComponentValue>

Column

Gets the 1-based column the value starts at, or 0 when unknown.

public override int Column { get; }

Property Value

int

Line

Gets the 1-based line the value starts on, or 0 when unknown.

public override int Line { get; }

Property Value

int

Name

The function name, as written (with escapes resolved).

public string Name { get; init; }

Property Value

string

Methods

Equals(CssFunction?)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(CssFunction? other)

Parameters

other CssFunction

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

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

lowercaseName string

The name in lowercase.

Returns

bool

True when the names match.