Table of Contents

Class BytesValue

Namespace
WebDriverBiDi.Network
Assembly
WebDriverBiDi.dll

Represents a value that can contain either a string or a byte array.

public record BytesValue : IEquatable<BytesValue>
Inheritance
BytesValue
Implements
Inherited Members

Constructors

BytesValue(BytesValue)

protected BytesValue(BytesValue original)

Parameters

original BytesValue

Properties

EqualityContract

protected virtual Type EqualityContract { get; }

Property Value

Type

Type

Gets the type of the value object.

[JsonPropertyName("type")]
[JsonRequired]
[JsonInclude]
public BytesValueType Type { get; }

Property Value

BytesValueType

Value

Gets the value of the value object.

[JsonPropertyName("value")]
[JsonRequired]
[JsonInclude]
public string Value { get; }

Property Value

string

ValueAsByteArray

Gets the value of the value object as an array of bytes.

[JsonIgnore]
public byte[] ValueAsByteArray { get; }

Property Value

byte[]

Methods

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

Equals(BytesValue?)

public virtual bool Equals(BytesValue? other)

Parameters

other BytesValue

Returns

bool

FromBase64String(string)

Creates a BytesValue object from a base64-encoded string value.

public static BytesValue FromBase64String(string base64Value)

Parameters

base64Value string

The value of the BytesValue as a base64-encoded string.

Returns

BytesValue

The BytesValue representing the value.

FromByteArray(byte[])

Creates a BytesValue object containing a base64-encoded string from an array of bytes.

public static BytesValue FromByteArray(byte[] bytes)

Parameters

bytes byte[]

The value of the BytesValue as a byte array.

Returns

BytesValue

The BytesValue representing the value.

FromString(string)

Creates a BytesValue object from a string value.

public static BytesValue FromString(string stringValue)

Parameters

stringValue string

The string value the BytesValue contains.

Returns

BytesValue

The BytesValue representing the string.

GetHashCode()

public override int GetHashCode()

Returns

int

PrintMembers(StringBuilder)

Prints the members of this value for ToString(): its Type and Value.

protected virtual bool PrintMembers(StringBuilder builder)

Parameters

builder StringBuilder

The builder to print the members to.

Returns

bool

true, because members were printed.

Remarks

ValueAsByteArray is deliberately not printed. It decodes the whole value each time it is read, which would make printing a large body expensive only to print the name of the array type, and it throws for a Base64 value that is not valid base64, which would make ToString() throw. Value already shows the content.

ToString()

public override string ToString()

Returns

string

Operators

operator ==(BytesValue?, BytesValue?)

public static bool operator ==(BytesValue? left, BytesValue? right)

Parameters

left BytesValue
right BytesValue

Returns

bool

operator !=(BytesValue?, BytesValue?)

public static bool operator !=(BytesValue? left, BytesValue? right)

Parameters

left BytesValue
right BytesValue

Returns

bool