Skip to content

Commit

Permalink
Stream extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
DomCR committed Nov 4, 2024
1 parent 3981033 commit 041deaf
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions CSUtilities/CSUtilities.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<Compile Include="$(MSBuildThisFileDirectory)EnvironmentVars.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Extensions\IDictionaryExtension.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Extensions\ObjectExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Extensions\StreamExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Extensions\StringBuilderExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Text\CodePage.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Converters\DefaultEndianConverter.cs" />
Expand Down
29 changes: 29 additions & 0 deletions CSUtilities/Extensions/StreamExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System.IO;

namespace CSUtilities.Extensions
{
/// <summary>
/// Stream utility extensions.
/// </summary>
#if PUBLIC
public
#else
internal
#endif
static class StreamExtensions
{
#if NETFRAMEWORK
/// <summary>
/// When overridden in a derived class, writes a sequence of bytes to the current
/// stream and advances the current position within this stream by the number of
/// bytes written.
/// </summary>
/// <param name="stream"></param>
/// <param name="buffer">A region of memory. This method copies the contents of this region to the current stream. </param>
public static void Write(this Stream stream, byte[] buffer)
{
stream.Write(buffer, 0, buffer.Length);
}
#endif
}
}
2 changes: 1 addition & 1 deletion CSUtilities/Extensions/StringBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static class StringBuilderExtensions
{
#if NETFRAMEWORK
/// <summary>
///
/// Concatenates and appends the members of a collection, using the specified separator between each member.
/// </summary>
public static StringBuilder AppendJoin<T>(this StringBuilder sb, string? separator, IEnumerable<T> values)
{
Expand Down

0 comments on commit 041deaf

Please sign in to comment.