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
originalBytesValue
Properties
EqualityContract
protected virtual Type EqualityContract { get; }
Property Value
Type
Gets the type of the value object.
[JsonPropertyName("type")]
[JsonRequired]
[JsonInclude]
public BytesValueType Type { get; }
Property Value
Value
Gets the value of the value object.
[JsonPropertyName("value")]
[JsonRequired]
[JsonInclude]
public string Value { get; }
Property Value
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
objobject
Returns
Equals(BytesValue?)
public virtual bool Equals(BytesValue? other)
Parameters
otherBytesValue
Returns
FromBase64String(string)
Creates a BytesValue object from a base64-encoded string value.
public static BytesValue FromBase64String(string base64Value)
Parameters
base64ValuestringThe 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
bytesbyte[]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
stringValuestringThe string value the BytesValue contains.
Returns
- BytesValue
The BytesValue representing the string.
GetHashCode()
public override int GetHashCode()
Returns
PrintMembers(StringBuilder)
Prints the members of this value for ToString(): its Type and Value.
protected virtual bool PrintMembers(StringBuilder builder)
Parameters
builderStringBuilderThe builder to print the members to.
Returns
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
Operators
operator ==(BytesValue?, BytesValue?)
public static bool operator ==(BytesValue? left, BytesValue? right)
Parameters
leftBytesValuerightBytesValue
Returns
operator !=(BytesValue?, BytesValue?)
public static bool operator !=(BytesValue? left, BytesValue? right)
Parameters
leftBytesValuerightBytesValue