Skip to content

Commit

Permalink
Apply IDisposable to BinaryPacket.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
Linwenxuan authored and Linwenxuan committed Oct 11, 2023
1 parent 5650001 commit 2b59c52
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Lagrange.Core/Utility/Binary/BinaryPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Lagrange.Core.Utility.Binary;
/// Binary Writer, Inspired by <see cref="System.IO.BinaryWriter"/>
/// <para>Provide only Sync Apis</para>
/// </summary>
internal partial class BinaryPacket
internal partial class BinaryPacket : IDisposable
{
private readonly MemoryStream _stream;

Expand Down Expand Up @@ -295,4 +295,10 @@ public static bool InsertPrefix(byte[] buffer, uint offset, uint value, Prefix p
public bool IsAvailable(int length) => _stream.Length - _stream.Position >= length;

public byte[] ToArray() => _stream.ToArray();

public void Dispose()
{
_stream.Dispose();
_reader.Dispose();
}
}

0 comments on commit 2b59c52

Please sign in to comment.