Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JKorf committed Mar 21, 2024
1 parent e86713e commit 108c8fc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,9 @@ public async Task<bool> Read(Stream stream, bool bufferStream)
// We don't need to buffer the stream, so don't bother keeping the reference
}

var length = stream.CanSeek ? stream.Length : 4096;
using var reader = new StreamReader(stream, Encoding.UTF8, false, (int)Math.Max(2, length), true);
var readStream = _stream ?? stream;
var length = readStream.CanSeek ? readStream.Length : 4096;
using var reader = new StreamReader(readStream, Encoding.UTF8, false, (int)Math.Max(2, length), true);
using var jsonTextReader = new JsonTextReader(reader);

try
Expand Down
2 changes: 2 additions & 0 deletions CryptoExchange.Net/Converters/SystemTextJson/EnumConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ public EnumConverterInner(bool writeAsInt, bool warnOnMissingEntry)
{
JsonTokenType.String => reader.GetString(),
JsonTokenType.Number => reader.GetInt16().ToString(),
JsonTokenType.True => "true",
JsonTokenType.False => "false",
_ => null
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public async Task<bool> Read(Stream stream, bool bufferStream)

try
{
_document = await JsonDocument.ParseAsync(stream).ConfigureAwait(false);
_document = await JsonDocument.ParseAsync(_stream ?? stream).ConfigureAwait(false);
IsJson = true;
}
catch (Exception)
Expand Down

0 comments on commit 108c8fc

Please sign in to comment.