Edit

Share via


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)

Creates a BinaryData instance by wrapping the provided byte array and sets MediaType to <see pref="mediaType"></see> value.

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)

Creates a BinaryData instance by wrapping the provided bytes and sets MediaType to <see pref="mediaType"></see> value.

BinaryData(ReadOnlyMemory<Byte>)

Creates a BinaryData instance by wrapping the provided bytes.

BinaryData(String, String)

Creates a BinaryData instance from a string by converting the string to bytes using the UTF-8 encoding and sets MediaType to <see pref="mediaType"></see> value.

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

Gets the The MIME type of this data, for example, Octet.

Methods

Equals(Object)

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

FromBytes(Byte[], String)

Creates a BinaryData instance by wrapping the provided byte array and sets MediaType to <see pref="mediaType"></see> value.

FromBytes(Byte[])

Creates a BinaryData instance by wrapping the provided byte array.

FromBytes(ReadOnlyMemory<Byte>, String)

Creates a BinaryData instance by wrapping the provided ReadOnlyMemory<T> and sets MediaType to <see pref="mediaType"></see> value.

FromBytes(ReadOnlyMemory<Byte>)

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

FromFile(String, String)

Creates a BinaryData instance from the specified file and sets MediaType to <see pref="mediaType"></see> value.

FromFile(String)

Creates a BinaryData instance from the specified file.

FromFileAsync(String, CancellationToken)

Creates a BinaryData instance from the specified file.

FromFileAsync(String, String, CancellationToken)

Creates a BinaryData instance from the specified file and sets MediaType to <see pref="mediaType"></see> value.

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)

Creates a BinaryData instance from the specified stream and sets MediaType to <see pref="mediaType"></see> value.

The stream is not disposed by this method.

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)

Creates a BinaryData instance from the specified stream and sets MediaType to <see pref="mediaType"></see> value.

The stream is not disposed by this method.

FromString(String, String)

Creates a BinaryData instance from a string by converting the string to bytes using the UTF-8 encoding and sets MediaType to <see pref="mediaType"></see> value.

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.

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)

Creates a BinaryData instance by wrapping the same data and changed MediaType to <see pref="mediaType"></see> value.

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