Esempio n. 1
0
 /// <summary>
 /// Asynchronously reads the next JSON token from the source as a <see cref="string"/>.
 /// </summary>
 /// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None"/>.</param>
 /// <returns>A <see cref="Task{TResult}"/> that represents the asynchronous read. The <see cref="Task{TResult}.Result"/>
 /// property returns the <see cref="string"/>. This result will be <c>null</c> at the end of an array.</returns>
 /// <remarks>The default behaviour is to execute synchronously, returning an already-completed task. Derived
 /// classes can override this behaviour for true asynchronicity.</remarks>
 public virtual Task <string?> ReadAsStringAsync(
     CancellationToken cancellationToken = default
     )
 {
     return(cancellationToken.CancelIfRequestedAsync <string?>()
            ?? Task.FromResult(ReadAsString()));
 }
Esempio n. 2
0
 /// <summary>
 /// Asynchronously reads the next JSON token from the source as a <see cref="Nullable{T}"/> of <see cref="decimal"/>.
 /// </summary>
 /// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None"/>.</param>
 /// <returns>A <see cref="Task{TResult}"/> that represents the asynchronous read. The <see cref="Task{TResult}.Result"/>
 /// property returns the <see cref="Nullable{T}"/> of <see cref="decimal"/>. This result will be <c>null</c> at the end of an array.</returns>
 /// <remarks>The default behaviour is to execute synchronously, returning an already-completed task. Derived
 /// classes can override this behaviour for true asynchronicity.</remarks>
 public virtual Task <decimal?> ReadAsDecimalAsync(
     CancellationToken cancellationToken = default
     )
 {
     return(cancellationToken.CancelIfRequestedAsync <decimal?>()
            ?? Task.FromResult(ReadAsDecimal()));
 }
Esempio n. 3
0
 /// <summary>
 /// Asynchronously reads the next JSON token from the source as a <see cref="Nullable{T}"/> of <see cref="DateTimeOffset"/>.
 /// </summary>
 /// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None"/>.</param>
 /// <returns>A <see cref="Task{TResult}"/> that represents the asynchronous read. The <see cref="Task{TResult}.Result"/>
 /// property returns the <see cref="Nullable{T}"/> of <see cref="DateTimeOffset"/>. This result will be <c>null</c> at the end of an array.</returns>
 /// <remarks>The default behaviour is to execute synchronously, returning an already-completed task. Derived
 /// classes can override this behaviour for true asynchronicity.</remarks>
 public virtual Task <DateTimeOffset?> ReadAsDateTimeOffsetAsync(
     CancellationToken cancellationToken = default
     )
 {
     return(cancellationToken.CancelIfRequestedAsync <DateTimeOffset?>()
            ?? Task.FromResult(ReadAsDateTimeOffset()));
 }
Esempio n. 4
0
        public static Task WriteEscapedJavaScriptStringAsync(TextWriter writer, string s, char delimiter, bool appendDelimiters, bool[] charEscapeFlags, StringEscapeHandling stringEscapeHandling, JsonTextWriter client, char[] writeBuffer, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (appendDelimiters)
            {
                return(WriteEscapedJavaScriptStringWithDelimitersAsync(writer, s, delimiter, charEscapeFlags, stringEscapeHandling, client, writeBuffer, cancellationToken));
            }

            if (string.IsNullOrEmpty(s))
            {
                return(cancellationToken.CancelIfRequestedAsync() ?? AsyncUtils.CompletedTask);
            }

            return(WriteEscapedJavaScriptStringWithoutDelimitersAsync(writer, s, charEscapeFlags, stringEscapeHandling, client, writeBuffer, cancellationToken));
        }
 /// <summary>
 /// Asynchronously reads the next JSON token from the source as a <see cref="Nullable{T}"/> of <see cref="bool"/>.
 /// </summary>
 /// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None"/>.</param>
 /// <returns>A <see cref="Task{TResult}"/> that represents the asynchronous read. The <see cref="Task{TResult}.Result"/>
 /// property returns the <see cref="Nullable{T}"/> of <see cref="bool"/>. This result will be <c>null</c> at the end of an array.</returns>
 /// <remarks>The default behaviour is to execute synchronously, returning an already-completed task. Derived
 /// classes can override this behaviour for true asynchronicity.</remarks>
 public virtual Task <bool?> ReadAsBooleanAsync(CancellationToken cancellationToken = default)
 {
     return(cancellationToken.CancelIfRequestedAsync <bool?>() ?? Task.FromResult(ReadAsBoolean()));
 }
 /// <summary>
 /// Asynchronously reads the next JSON token from the source.
 /// </summary>
 /// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None"/>.</param>
 /// <returns>A <see cref="Task{TResult}"/> that represents the asynchronous read. The <see cref="Task{TResult}.Result"/>
 /// property returns <c>true</c> if the next token was read successfully; <c>false</c> if there are no more tokens to read.</returns>
 /// <remarks>The default behaviour is to execute synchronously, returning an already-completed task. Derived
 /// classes can override this behaviour for true asynchronicity.</remarks>
 public virtual Task <bool> ReadAsync(CancellationToken cancellationToken = default)
 {
     return(cancellationToken.CancelIfRequestedAsync <bool>() ?? Read().ToAsync());
 }
 /// <summary>
 /// Asynchronously reads the next JSON token from the source as a <see cref="Nullable{T}"/> of <see cref="int"/>.
 /// </summary>
 /// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None"/>.</param>
 /// <returns>A <see cref="Task{TResult}"/> that represents the asynchronous read. The <see cref="Task{TResult}.Result"/>
 /// property returns the <see cref="Nullable{T}"/> of <see cref="int"/>. This result will be <c>null</c> at the end of an array.</returns>
 /// <remarks>The default behaviour is to execute synchronously, returning an already-completed task. Derived
 /// classes can override this behaviour for true asynchronicity.</remarks>
 public virtual Task <int?> ReadAsInt32Async(CancellationToken cancellationToken = default)
 {
     return(cancellationToken.CancelIfRequestedAsync <int?>() ?? Task.FromResult(ReadAsInt32()));
 }
 /// <summary>
 /// Asynchronously reads the next JSON token from the source as a <see cref="byte"/>[].
 /// </summary>
 /// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is <see cref="CancellationToken.None"/>.</param>
 /// <returns>A <see cref="Task{TResult}"/> that represents the asynchronous read. The <see cref="Task{TResult}.Result"/>
 /// property returns the <see cref="byte"/>[]. This result will be <c>null</c> at the end of an array.</returns>
 /// <remarks>The default behaviour is to execute synchronously, returning an already-completed task. Derived
 /// classes can override this behaviour for true asynchronicity.</remarks>
 public virtual Task <byte[]> ReadAsBytesAsync(CancellationToken cancellationToken = default)
 {
     return(cancellationToken.CancelIfRequestedAsync <byte[]>() ?? Task.FromResult(ReadAsBytes()));
 }
Esempio n. 9
0
 public virtual Task <bool> ReadAsync(CancellationToken cancellationToken = null)
 {
     return(cancellationToken.CancelIfRequestedAsync <bool>() ?? this.Read().ToAsync());
 }
Esempio n. 10
0
 public virtual Task <string> ReadAsStringAsync(CancellationToken cancellationToken = null)
 {
     return(cancellationToken.CancelIfRequestedAsync <string>() ?? Task.FromResult <string>(this.ReadAsString()));
 }
Esempio n. 11
0
 public virtual Task <int?> ReadAsInt32Async(CancellationToken cancellationToken = null)
 {
     return(cancellationToken.CancelIfRequestedAsync <int?>() ?? Task.FromResult <int?>(this.vmethod_0()));
 }
Esempio n. 12
0
 public virtual Task <DateTime?> ReadAsDateTimeAsync(CancellationToken cancellationToken = null)
 {
     return(cancellationToken.CancelIfRequestedAsync <DateTime?>() ?? Task.FromResult <DateTime?>(this.ReadAsDateTime()));
 }
Esempio n. 13
0
 public virtual Task <SmallDec> ReadAsSmallDecAsync(CancellationToken cancellationToken = default(CancellationToken))
 {
     return(cancellationToken.CancelIfRequestedAsync <SmallDec>() ?? Task.FromResult(ReadAsSmallDec()));
 }