Table of Contents

Class CssTokenValue

Namespace
Egami.Css
Assembly
Egami.Css.dll

A token kept as a component value: any token other than a function or an opening bracket.

public sealed record CssTokenValue : CssComponentValue, IEquatable<CssComponentValue>, IEquatable<CssTokenValue>
Inheritance
CssTokenValue
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

CssTokenValue(CssToken)

A token kept as a component value: any token other than a function or an opening bracket.

public CssTokenValue(CssToken Token)

Parameters

Token CssToken

The token.

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

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

Token

The token.

public CssToken Token { get; init; }

Property Value

CssToken

Methods

Equals(CssTokenValue?)

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

public bool Equals(CssTokenValue? other)

Parameters

other CssTokenValue

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.