BinaryData Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
A lightweight abstraction for a payload of bytes that supports converting between string, stream, JSON, and bytes.
public class BinaryData
type BinaryData = class
Public Class BinaryData
- Inheritance
-
System.ObjectBinaryData
Constructors
BinaryData(Byte[]) |
Creates a BinaryData instance by wrapping the provided byte array. |
BinaryData(Object, JsonSerializerOptions, Type) |
Creates a BinaryData instance by serializing the provided object to JSON using System.Text.Json.JsonSerializer. |
BinaryData(ReadOnlyMemory<Byte>) |
Creates a BinaryData instance by wrapping the provided bytes. |
BinaryData(String) |
Creates a BinaryData instance from a string by converting the string to bytes using the UTF-8 encoding. |
Methods
FromBytes(Byte[]) |
Creates a BinaryData instance by wrapping the provided byte array. |
FromBytes(ReadOnlyMemory<Byte>) |
Creates a BinaryData instance by wrapping the provided System.ReadOnlyMemory`1. |
FromObjectAsJson<T>(T, JsonSerializerOptions) |
Creates a BinaryData instance by serializing the provided object using the System.Text.Json.JsonSerializer. |
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. |
FromString(String) |
Creates a BinaryData instance from a string by converting the string to bytes using the UTF-8 encoding. |
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 System.Text.Json.JsonSerializer. |
ToStream() |
Converts the BinaryData to a read-only stream. |
ToString() |
Converts the value of this instance to a string using UTF-8. |
Operators
Implicit(BinaryData to ReadOnlyMemory<Byte>) | |
Implicit(BinaryData to ReadOnlySpan<Byte>) |
Extension Methods
ToObject<T>(BinaryData, ObjectSerializer, CancellationToken) |
Converts the BinaryData to the specified type using the provided ObjectSerializer. |
ToObjectAsync<T>(BinaryData, ObjectSerializer, CancellationToken) |
Converts the BinaryData to the specified type using the provided ObjectSerializer. |