Muokkaa

Jaa


BinaryData Class

Definition

A lightweight abstraction for a payload of bytes that supports converting between string, stream, JSON, and bytes.

public ref class BinaryData
[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.BinaryDataJsonConverter))]
public class BinaryData
[<System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.BinaryDataJsonConverter))>]
type BinaryData = class
Public Class BinaryData
Inheritance
BinaryData
Attributes

Constructors

BinaryData(Byte[], String)
BinaryData(Byte[])

Creates a BinaryData instance by wrapping the provided byte array.

BinaryData(Object, JsonSerializerContext, Type)

Creates a BinaryData instance by serializing the provided object to JSON using JsonSerializer.

BinaryData(Object, JsonSerializerOptions, Type)

Creates a BinaryData instance by serializing the provided object to JSON using JsonSerializer.

BinaryData(ReadOnlyMemory<Byte>, String)
BinaryData(ReadOnlyMemory<Byte>)

Creates a BinaryData instance by wrapping the provided bytes.

BinaryData(String, String)
BinaryData(String)

Creates a BinaryData instance from a string by converting the string to bytes using the UTF-8 encoding.

Properties

Empty

Returns an empty BinaryData.

IsEmpty

Gets a value that indicates whether this data is empty.

Length

Gets the number of bytes of this data.

MediaType

Methods

Equals(Object)

Determines whether the specified object is equal to the current object.

FromBytes(Byte[], String)
FromBytes(Byte[])

Creates a BinaryData instance by wrapping the provided byte array.

FromBytes(ReadOnlyMemory<Byte>, String)
FromBytes(ReadOnlyMemory<Byte>)

Creates a BinaryData instance by wrapping the provided ReadOnlyMemory<T>.

FromObjectAsJson<T>(T, JsonSerializerOptions)

Creates a BinaryData instance by serializing the provided object using the JsonSerializer.

FromObjectAsJson<T>(T, JsonTypeInfo<T>)

Creates a BinaryData instance by serializing the provided object using the JsonSerializer.

FromStream(Stream, String)
FromStream(Stream)

Creates a BinaryData instance from the specified stream. The stream is not disposed by this method.

FromStreamAsync(Stream, CancellationToken)

Creates a BinaryData instance from the specified stream. The stream is not disposed by this method.

FromStreamAsync(Stream, String, CancellationToken)
FromString(String, String)
FromString(String)

Creates a BinaryData instance from a string by converting the string to bytes using the UTF-8 encoding.

GetHashCode()

Returns the hash code for the current BinaryData object.

GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToArray()

Converts the BinaryData to a byte array.

ToMemory()

Gets the value of this instance as bytes without any further interpretation.

ToObjectFromJson<T>(JsonSerializerOptions)

Converts the BinaryData to the specified type using JsonSerializer.

ToObjectFromJson<T>(JsonTypeInfo<T>)

Converts the BinaryData to the specified type using JsonSerializer.

ToStream()

Converts the BinaryData to a read-only stream.

ToString()

Converts the value of this instance to a string using UTF-8.

WithMediaType(String)

Operators

Implicit(BinaryData to ReadOnlyMemory<Byte>)

Defines an implicit conversion from a BinaryData to a ReadOnlyMemory<T>.

Implicit(BinaryData to ReadOnlySpan<Byte>)

Defines an implicit conversion from a BinaryData to a ReadOnlySpan<T>.

Applies to