Table of Contents

Class CssSimpleBlock

Namespace
Egami.Css
Assembly
Egami.Css.dll

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

OpenToken char

The opening character: (, [ or {.

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

char

Column

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

public override int Column { get; }

Property Value

int

Content

The content, including whitespace.

public IReadOnlyList<CssComponentValue> Content { get; init; }

Property Value

IReadOnlyList<CssComponentValue>

Line

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

public override int Line { get; }

Property Value

int

OpenToken

The opening character: (, [ or {.

public char OpenToken { get; init; }

Property Value

char

Methods

Equals(CssSimpleBlock?)

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

public bool Equals(CssSimpleBlock? other)

Parameters

other CssSimpleBlock

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.