Skip to content

Commit

Permalink
Add missing method to IJsonReaderAsync interface plus improvements (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
gathogojr authored Oct 8, 2021
1 parent ffd2459 commit a95aaad
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
24 changes: 22 additions & 2 deletions src/Microsoft.OData.Core/Json/IJsonReaderAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace Microsoft.OData.Json
{
using System.Threading.Tasks;

/// <summary>
/// Interface for a class that can read arbitrary JSON asynchronously.
/// </summary>
Expand All @@ -14,7 +16,25 @@ public interface IJsonReaderAsync
/// <summary>
/// Asynchronously reads the next node from the input.
/// </summary>
/// <returns>true if a new node was found, or false if end of input was reached.</returns>
bool ReadAsync();
/// <returns>A task that represents the asynchronous operation.
/// The value of the TResult parameter contains true if a new node was found, or false if end of input was reached.</returns>
Task<bool> ReadAsync();

/// <summary>
/// Asynchronously returns the value of the last reported node.
/// </summary>
/// <returns>A task that represents the asynchronous operation.
/// The value of the TResult parameter contains the value of the last reported node.</returns>
/// <remarks>A non-null is returned only if the last node was a PrimitiveValue or Property.
/// If the last node was a PrimitiveValue this property returns the value:
/// - null if the null token was found.
/// - boolean if the true or false token was found.
/// - string if a string token was found.
/// - DateTime if a string token formatted as DateTime was found.
/// - Int32 if a number which fits into the Int32 was found.
/// - Double if a number which doesn't fit into Int32 was found.
/// If the last node is a Property this property returns a string which is the name of the property.
/// </remarks>
Task<object> GetValueAsync();
}
}
4 changes: 2 additions & 2 deletions src/Microsoft.OData.Core/Json/IJsonReaderFactoryAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
// </copyright>
//---------------------------------------------------------------------

using System.IO;

namespace Microsoft.OData.Json
{
using System.IO;

/// <summary>
/// Interface of the factory to create asynchronous JSON readers.
/// </summary>
Expand Down
6 changes: 4 additions & 2 deletions src/Microsoft.OData.Core/Json/IJsonStreamReaderAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ public interface IJsonStreamReaderAsync : IJsonReaderAsync
/// <summary>
/// Asynchronously creates a Stream for reading a binary value.
/// </summary>
/// <returns>A Stream for reading the binary value.</returns>
/// <returns>A task that represents the asynchronous operation.
/// The value of the TResult parameter contains a <see cref="Stream"/> for reading the binary value.</returns>
Task<Stream> CreateReadStreamAsync();

/// <summary>
/// Asynchronously creates a TextReader for reading a string value.
/// </summary>
/// <returns>A TextReader for reading the string value.</returns>
/// <returns>A task that represents the asynchronous operation.
/// The value of the TResult parameter contains a <see cref="TextReader"/> for reading the string value.</returns>
Task<TextReader> CreateTextReaderAsync();
}
}

0 comments on commit a95aaad

Please sign in to comment.