Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ public Task SerializeAsync<T>(T data, Stream stream, SerializationFormatting for

public T Deserialize<T>(Stream stream)
{
if (stream == null || stream.Length == 0) return default(T);
if (stream == null || stream.CanSeek && stream.Length == 0) return default(T);
using (var streamReader = new StreamReader(stream))
using (var jsonTextReader = new JsonTextReader(streamReader))
return this.Serializer.Deserialize<T>(jsonTextReader);
}

public object Deserialize(Type type, Stream stream)
{
if (stream == null || stream.Length == 0) return type.DefaultValue();
if (stream == null || stream.CanSeek && stream.Length == 0) return type.DefaultValue();
using (var streamReader = new StreamReader(stream))
using (var jsonTextReader = new JsonTextReader(streamReader))
return this.Serializer.Deserialize(jsonTextReader, type);
Expand All @@ -103,7 +103,7 @@ public object Deserialize(Type type, Stream stream)
public async Task<T> DeserializeAsync<T>(Stream stream, CancellationToken cancellationToken = default(CancellationToken))
#pragma warning restore 1998
{
if (stream == null || stream.Length == 0) return default(T);
if (stream == null || stream.CanSeek && stream.Length == 0) return default(T);
using (var sr = new StreamReader(stream))
using (var jtr = new JsonTextReader(sr))
return this.Serializer.Deserialize<T>(jtr);
Expand All @@ -113,7 +113,7 @@ public object Deserialize(Type type, Stream stream)
public async Task<object> DeserializeAsync(Type type, Stream stream, CancellationToken cancellationToken = default(CancellationToken))
#pragma warning restore 1998
{
if (stream == null || stream.Length == 0) return type.DefaultValue();
if (stream == null || stream.CanSeek && stream.Length == 0) return type.DefaultValue();
using (var sr = new StreamReader(stream))
using (var jtr = new JsonTextReader(sr))
return this.Serializer.Deserialize(jtr, type);
Expand Down