Async JToken methods

This commit is contained in:
Jon Hanna
2017-01-09 23:44:08 +13:00
committed by James Newton-King
parent dde1d905df
commit c9b2ec8055
33 changed files with 3102 additions and 13 deletions
+25
View File
@@ -204,6 +204,31 @@ namespace Newtonsoft.Json
{
return cancellationToken.CancelIfRequestedAsync<string>() ?? Task.FromResult(ReadAsString());
}
internal async Task<bool> ReadAndMoveToContentAsync(CancellationToken cancellationToken)
{
return await ReadAsync(cancellationToken).ConfigureAwait(false) && await MoveToContentAsync(cancellationToken).ConfigureAwait(false);
}
internal async Task<bool> MoveToContentAsync(CancellationToken cancellationToken)
{
while (true)
{
switch (TokenType)
{
case JsonToken.None:
case JsonToken.Comment:
if (!await ReadAsync(cancellationToken).ConfigureAwait(false))
{
return false;
}
break;
default:
return true;
}
}
}
}
}