Skip to content

Commit

Permalink
resolves #155 🚜✨
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanWilhite committed Jan 29, 2024
1 parent 437cde2 commit b93add3
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
26 changes: 26 additions & 0 deletions SonghayCore/Extensions/ByteExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
namespace Songhay.Extensions;

/// <summary>
/// Extensions of <see cref="byte"/>.
/// </summary>
public static class ByteExtensions
{
/// <summary>
/// Converts the specified <see cref="byte"/> array to a <see cref="StreamReader"/>
/// with <see cref="Encoding.UTF8"/>.
/// </summary>
/// <param name="bytes">the bytes</param>
public static StreamReader ToStreamReader(this byte[] bytes) => bytes.ToStreamReader(Encoding.UTF8);

/// <summary>
/// Converts the specified <see cref="byte"/> array to a <see cref="StreamReader"/>.
/// </summary>
/// <param name="bytes">the bytes</param>
/// <param name="encoding">the encoding</param>
/// <remarks>
/// This member is useful in the world of ASP.NET when there is a need
/// to read a <see cref="string"/> from the bytes of a <c>MultipartSection"</c>.
/// </remarks>
public static StreamReader ToStreamReader(this byte[] bytes, Encoding encoding) =>
new(new MemoryStream(bytes), encoding);
}
23 changes: 23 additions & 0 deletions SonghayCore/SonghayCore.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b93add3

Please sign in to comment.