Upload hot garbage

This commit is contained in:
2024-11-25 21:45:10 +04:00
commit 2d751f9414
847 changed files with 704796 additions and 0 deletions

Binary file not shown.

View File

@@ -0,0 +1,17 @@
# Release History
## 1.0.2 (2021-04-07)
- Add System.Text.Encodings.Web dependency
## 1.0.1 (2020-11-16)
- Fix issue where if the type was not passed into the constructor, an exception would be thrown instead of defaulting to
calling GetType().
## 1.0.0 (2020-11-03)
- The general availability release of System.Memory.Data package.
## 1.0.0-beta.2 (2020-11-03)
- Update package icon.
## 1.0.0-beta.1 (2020-11-02)
- Moving BinaryData to System namespace.

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

@@ -0,0 +1,67 @@
# System.Memory.Data library for .NET
## Binary Data
The `BinaryData` type provides a lightweight abstraction for a payload of bytes. It provides convenient helper methods to get out commonly used primitives, such as streams, strings, or bytes. The assumption when converting to and from string is that the encoding is UTF-8.
### Data ownership
When using the `byte[]` or `ReadOnlyMemory<byte>` constructors or methods, `BinaryData` will wrap the passed in bytes. When using streams, strings, or rich model types that will be serialized as Json, the data is converted into bytes and will be maintained by `BinaryData`. Thus, if you are using bytes to create your instance of `BinaryData`, changes to the underlying data will be reflected in `BinaryData` as it does not copy the bytes.
### Usage
The main value of this type is its ability to easily convert from string to bytes to stream. This can greatly simplify API surface areas by exposing this type as opposed to numerous overloads or properties.
To/From string:
```C# Snippet:BinaryDataToFromString
var data = new BinaryData("some data");
// ToString will decode the bytes using UTF-8
Console.WriteLine(data.ToString()); // prints "some data"
```
To/From bytes:
```C# Snippet:BinaryDataToFromBytes
byte[] bytes = Encoding.UTF8.GetBytes("some data");
// Create BinaryData using a constructor ...
BinaryData data = new BinaryData(bytes);
// Or using a static factory method.
data = BinaryData.FromBytes(bytes);
// There is an implicit cast defined for ReadOnlyMemory<byte>
ReadOnlyMemory<byte> rom = data;
// There is also an implicit cast defined for ReadOnlySpan<byte>
ReadOnlySpan<byte> ros = data;
// there is also a ToMemory method that gives access to the ReadOnlyMemory.
rom = data.ToMemory();
// and a ToArray method that converts into a byte array.
byte[] array = data.ToArray();
```
To/From stream:
```C# Snippet:BinaryDataToFromStream
var bytes = Encoding.UTF8.GetBytes("some data");
Stream stream = new MemoryStream(bytes);
var data = BinaryData.FromStream(stream);
// Calling ToStream will give back a stream that is backed by ReadOnlyMemory, so it is not writable.
stream = data.ToStream();
Console.WriteLine(stream.CanWrite); // prints false
```
`BinaryData` also can be used to integrate with `ObjectSerializer`. By default, the `JsonObjectSerializer` will be used, but any serializer deriving from `ObjectSerializer` can be used.
```C# Snippet:BinaryDataToFromCustomModel
var model = new CustomModel
{
A = "some text",
B = 5,
C = true
};
var data = BinaryData.FromObjectAsJson(model);
model = data.ToObjectFromJson<CustomModel>();
```

View File

@@ -0,0 +1,162 @@
<?xml version="1.0" encoding="utf-8"?>
<doc>
<assembly>
<name>System.Memory.Data</name>
</assembly>
<members>
<member name="T:System.BinaryData">
<summary>
A lightweight abstraction for a payload of bytes that supports converting between string, stream, JSON, and bytes.
</summary>
</member>
<member name="M:System.BinaryData.#ctor(System.Byte[])">
<summary>
Creates a <see cref="T:System.BinaryData" /> instance by wrapping the
provided byte array.
</summary>
<param name="data">The array to wrap.</param>
</member>
<member name="M:System.BinaryData.#ctor(System.Object,System.Text.Json.JsonSerializerOptions,System.Type)">
<summary>
Creates a <see cref="T:System.BinaryData" /> instance by serializing the provided object to JSON
using <see cref="T:System.Text.Json.JsonSerializer" />.
</summary>
<param name="jsonSerializable">The object that will be serialized to JSON using
<see cref="T:System.Text.Json.JsonSerializer" />.</param>
<param name="options">The options to use when serializing to JSON.</param>
<param name="type">The type to use when serializing the data. If not specified, <see cref="M:System.Object.GetType" /> will
be used to determine the type.</param>
</member>
<member name="M:System.BinaryData.#ctor(System.ReadOnlyMemory{System.Byte})">
<summary>
Creates a <see cref="T:System.BinaryData" /> instance by wrapping the
provided bytes.
</summary>
<param name="data">Byte data to wrap.</param>
</member>
<member name="M:System.BinaryData.#ctor(System.String)">
<summary>
Creates a <see cref="T:System.BinaryData" /> instance from a string by converting
the string to bytes using the UTF-8 encoding.
</summary>
<param name="data">The string data.</param>
</member>
<member name="M:System.BinaryData.FromBytes(System.ReadOnlyMemory{System.Byte})">
<summary>
Creates a <see cref="T:System.BinaryData" /> instance by wrapping the provided
<see cref="T:System.ReadOnlyMemory`1" />.
</summary>
<param name="data">Byte data to wrap.</param>
<returns>A wrapper over <paramref name="data" />.</returns>
</member>
<member name="M:System.BinaryData.FromBytes(System.Byte[])">
<summary>
Creates a <see cref="T:System.BinaryData" /> instance by wrapping the provided
byte array.
</summary>
<param name="data">The array to wrap.</param>
<returns>A wrapper over <paramref name="data" />.</returns>
</member>
<member name="M:System.BinaryData.FromString(System.String)">
<summary>
Creates a <see cref="T:System.BinaryData" /> instance from a string by converting
the string to bytes using the UTF-8 encoding.
</summary>
<param name="data">The string data.</param>
<returns>A value representing the UTF-8 encoding of <paramref name="data" />.</returns>
</member>
<member name="M:System.BinaryData.FromStream(System.IO.Stream)">
<summary>
Creates a <see cref="T:System.BinaryData" /> instance from the specified stream.
The stream is not disposed by this method.
</summary>
<param name="stream">Stream containing the data.</param>
<returns>A value representing all of the data remaining in <paramref name="stream" />.</returns>
</member>
<member name="M:System.BinaryData.FromStreamAsync(System.IO.Stream,System.Threading.CancellationToken)">
<summary>
Creates a <see cref="T:System.BinaryData" /> instance from the specified stream.
The stream is not disposed by this method.
</summary>
<param name="stream">Stream containing the data.</param>
<param name="cancellationToken">A token that may be used to cancel the operation.</param>
<returns>A value representing all of the data remaining in <paramref name="stream" />.</returns>
</member>
<member name="M:System.BinaryData.FromObjectAsJson``1(``0,System.Text.Json.JsonSerializerOptions)">
<summary>
Creates a <see cref="T:System.BinaryData" /> instance by serializing the provided object using
the <see cref="T:System.Text.Json.JsonSerializer" />.
</summary>
<typeparam name="T">The type to use when serializing the data.</typeparam>
<param name="jsonSerializable">The data to use.</param>
<param name="options">The options to use when serializing to JSON.</param>
<returns>A value representing the UTF-8 encoding of the JSON representation of <paramref name="jsonSerializable" />.</returns>
</member>
<member name="M:System.BinaryData.ToString">
<summary>
Converts the value of this instance to a string using UTF-8.
</summary>
<returns>
A string from the value of this instance, using UTF-8 to decode the bytes.
</returns>
</member>
<member name="M:System.BinaryData.ToStream">
<summary>
Converts the <see cref="T:System.BinaryData" /> to a read-only stream.
</summary>
<returns>A stream representing the data.</returns>
</member>
<member name="M:System.BinaryData.ToMemory">
<summary>
Gets the value of this instance as bytes without any further interpretation.
</summary>
<returns>The value of this instance as bytes without any further interpretation.</returns>
</member>
<member name="M:System.BinaryData.ToArray">
<summary>
Converts the <see cref="T:System.BinaryData" /> to a byte array.
</summary>
<returns>A byte array representing the data.</returns>
</member>
<member name="M:System.BinaryData.ToObjectFromJson``1(System.Text.Json.JsonSerializerOptions)">
<summary>
Converts the <see cref="T:System.BinaryData" /> to the specified type using
<see cref="T:System.Text.Json.JsonSerializer" />.
</summary>
<typeparam name="T">The type that the data should be
converted to.</typeparam>
<param name="options">The <see cref="T:System.Text.Json.JsonSerializerOptions" /> to use when serializing to JSON.</param>
<returns>The data converted to the specified type.</returns>
</member>
<member name="M:System.BinaryData.op_Implicit(System.BinaryData)~System.ReadOnlyMemory{System.Byte}">
<summary>
Defines an implicit conversion from a <see cref="T:System.BinaryData" /> to a <see cref="T:System.ReadOnlyMemory`1" />.
</summary>
<param name="data">The value to be converted.</param>
</member>
<member name="M:System.BinaryData.op_Implicit(System.BinaryData)~System.ReadOnlySpan{System.Byte}">
<summary>
Defines an implicit conversion from a <see cref="T:System.BinaryData" /> to a <see cref="T:System.ReadOnlySpan`1" />.
</summary>
<param name="data">The value to be converted.</param>
</member>
<member name="M:System.BinaryData.Equals(System.Object)">
<summary>
Determines whether the specified object is equal to the current object.
</summary>
<param name="obj">The object to compare with the current object.</param>
<returns>
<see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" />.
</returns>
</member>
<member name="M:System.BinaryData.GetHashCode">
<summary>Serves as the default hash function.</summary><returns>A hash code for the current object.</returns>
</member>
<member name="T:System.IO.ReadOnlyMemoryStream">
<summary>Provides a <see cref="T:System.IO.Stream" /> for the contents of a <see cref="T:System.ReadOnlyMemory`1" />.</summary>
</member>
</members>
</doc>

View File

@@ -0,0 +1,162 @@
<?xml version="1.0" encoding="utf-8"?>
<doc>
<assembly>
<name>System.Memory.Data</name>
</assembly>
<members>
<member name="T:System.BinaryData">
<summary>
A lightweight abstraction for a payload of bytes that supports converting between string, stream, JSON, and bytes.
</summary>
</member>
<member name="M:System.BinaryData.#ctor(System.Byte[])">
<summary>
Creates a <see cref="T:System.BinaryData" /> instance by wrapping the
provided byte array.
</summary>
<param name="data">The array to wrap.</param>
</member>
<member name="M:System.BinaryData.#ctor(System.Object,System.Text.Json.JsonSerializerOptions,System.Type)">
<summary>
Creates a <see cref="T:System.BinaryData" /> instance by serializing the provided object to JSON
using <see cref="T:System.Text.Json.JsonSerializer" />.
</summary>
<param name="jsonSerializable">The object that will be serialized to JSON using
<see cref="T:System.Text.Json.JsonSerializer" />.</param>
<param name="options">The options to use when serializing to JSON.</param>
<param name="type">The type to use when serializing the data. If not specified, <see cref="M:System.Object.GetType" /> will
be used to determine the type.</param>
</member>
<member name="M:System.BinaryData.#ctor(System.ReadOnlyMemory{System.Byte})">
<summary>
Creates a <see cref="T:System.BinaryData" /> instance by wrapping the
provided bytes.
</summary>
<param name="data">Byte data to wrap.</param>
</member>
<member name="M:System.BinaryData.#ctor(System.String)">
<summary>
Creates a <see cref="T:System.BinaryData" /> instance from a string by converting
the string to bytes using the UTF-8 encoding.
</summary>
<param name="data">The string data.</param>
</member>
<member name="M:System.BinaryData.FromBytes(System.ReadOnlyMemory{System.Byte})">
<summary>
Creates a <see cref="T:System.BinaryData" /> instance by wrapping the provided
<see cref="T:System.ReadOnlyMemory`1" />.
</summary>
<param name="data">Byte data to wrap.</param>
<returns>A wrapper over <paramref name="data" />.</returns>
</member>
<member name="M:System.BinaryData.FromBytes(System.Byte[])">
<summary>
Creates a <see cref="T:System.BinaryData" /> instance by wrapping the provided
byte array.
</summary>
<param name="data">The array to wrap.</param>
<returns>A wrapper over <paramref name="data" />.</returns>
</member>
<member name="M:System.BinaryData.FromString(System.String)">
<summary>
Creates a <see cref="T:System.BinaryData" /> instance from a string by converting
the string to bytes using the UTF-8 encoding.
</summary>
<param name="data">The string data.</param>
<returns>A value representing the UTF-8 encoding of <paramref name="data" />.</returns>
</member>
<member name="M:System.BinaryData.FromStream(System.IO.Stream)">
<summary>
Creates a <see cref="T:System.BinaryData" /> instance from the specified stream.
The stream is not disposed by this method.
</summary>
<param name="stream">Stream containing the data.</param>
<returns>A value representing all of the data remaining in <paramref name="stream" />.</returns>
</member>
<member name="M:System.BinaryData.FromStreamAsync(System.IO.Stream,System.Threading.CancellationToken)">
<summary>
Creates a <see cref="T:System.BinaryData" /> instance from the specified stream.
The stream is not disposed by this method.
</summary>
<param name="stream">Stream containing the data.</param>
<param name="cancellationToken">A token that may be used to cancel the operation.</param>
<returns>A value representing all of the data remaining in <paramref name="stream" />.</returns>
</member>
<member name="M:System.BinaryData.FromObjectAsJson``1(``0,System.Text.Json.JsonSerializerOptions)">
<summary>
Creates a <see cref="T:System.BinaryData" /> instance by serializing the provided object using
the <see cref="T:System.Text.Json.JsonSerializer" />.
</summary>
<typeparam name="T">The type to use when serializing the data.</typeparam>
<param name="jsonSerializable">The data to use.</param>
<param name="options">The options to use when serializing to JSON.</param>
<returns>A value representing the UTF-8 encoding of the JSON representation of <paramref name="jsonSerializable" />.</returns>
</member>
<member name="M:System.BinaryData.ToString">
<summary>
Converts the value of this instance to a string using UTF-8.
</summary>
<returns>
A string from the value of this instance, using UTF-8 to decode the bytes.
</returns>
</member>
<member name="M:System.BinaryData.ToStream">
<summary>
Converts the <see cref="T:System.BinaryData" /> to a read-only stream.
</summary>
<returns>A stream representing the data.</returns>
</member>
<member name="M:System.BinaryData.ToMemory">
<summary>
Gets the value of this instance as bytes without any further interpretation.
</summary>
<returns>The value of this instance as bytes without any further interpretation.</returns>
</member>
<member name="M:System.BinaryData.ToArray">
<summary>
Converts the <see cref="T:System.BinaryData" /> to a byte array.
</summary>
<returns>A byte array representing the data.</returns>
</member>
<member name="M:System.BinaryData.ToObjectFromJson``1(System.Text.Json.JsonSerializerOptions)">
<summary>
Converts the <see cref="T:System.BinaryData" /> to the specified type using
<see cref="T:System.Text.Json.JsonSerializer" />.
</summary>
<typeparam name="T">The type that the data should be
converted to.</typeparam>
<param name="options">The <see cref="T:System.Text.Json.JsonSerializerOptions" /> to use when serializing to JSON.</param>
<returns>The data converted to the specified type.</returns>
</member>
<member name="M:System.BinaryData.op_Implicit(System.BinaryData)~System.ReadOnlyMemory{System.Byte}">
<summary>
Defines an implicit conversion from a <see cref="T:System.BinaryData" /> to a <see cref="T:System.ReadOnlyMemory`1" />.
</summary>
<param name="data">The value to be converted.</param>
</member>
<member name="M:System.BinaryData.op_Implicit(System.BinaryData)~System.ReadOnlySpan{System.Byte}">
<summary>
Defines an implicit conversion from a <see cref="T:System.BinaryData" /> to a <see cref="T:System.ReadOnlySpan`1" />.
</summary>
<param name="data">The value to be converted.</param>
</member>
<member name="M:System.BinaryData.Equals(System.Object)">
<summary>
Determines whether the specified object is equal to the current object.
</summary>
<param name="obj">The object to compare with the current object.</param>
<returns>
<see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" />.
</returns>
</member>
<member name="M:System.BinaryData.GetHashCode">
<summary>Serves as the default hash function.</summary><returns>A hash code for the current object.</returns>
</member>
<member name="T:System.IO.ReadOnlyMemoryStream">
<summary>Provides a <see cref="T:System.IO.Stream" /> for the contents of a <see cref="T:System.ReadOnlyMemory`1" />.</summary>
</member>
</members>
</doc>