| | | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | | 2 | | // Licensed under the MIT License. |
| | | 3 | | |
| | | 4 | | using System.Collections.Generic; |
| | | 5 | | using System.Threading; |
| | | 6 | | using System.Threading.Tasks; |
| | | 7 | | using Azure.AI.FormRecognizer.Models; |
| | | 8 | | using Azure.AI.FormRecognizer.Training; |
| | | 9 | | |
| | | 10 | | namespace Azure.AI.FormRecognizer |
| | | 11 | | { |
| | | 12 | | /// <summary> |
| | | 13 | | /// The set of extension methods for the subclasses of <see cref="Operation{T}" />. |
| | | 14 | | /// </summary> |
| | | 15 | | public static class OperationExtensions |
| | | 16 | | { |
| | | 17 | | /// <summary> |
| | | 18 | | /// Periodically calls the server until the long-running operation completes. |
| | | 19 | | /// </summary> |
| | | 20 | | /// <param name="operation">The instance that this method was invoked on.</param> |
| | | 21 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | | 22 | | /// <returns>A <see cref="Response{T}"/> representing the result of the operation. It can be cast to a <see cref |
| | | 23 | | /// containing the recognized receipts.</returns> |
| | | 24 | | public static async Task<Response<RecognizedFormCollection>> WaitForCompletionAsync(this Task<RecognizeReceiptsO |
| | | 25 | | { |
| | 0 | 26 | | var o = await operation.ConfigureAwait(false); |
| | 0 | 27 | | return await o.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); |
| | 0 | 28 | | } |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// Periodically calls the server until the long-running operation completes. |
| | | 32 | | /// </summary> |
| | | 33 | | /// <param name="operation">The instance that this method was invoked on.</param> |
| | | 34 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | | 35 | | /// <returns>A <see cref="Response{T}"/> representing the result of the operation. It can be cast to a <see cref |
| | | 36 | | /// containing the recognized forms.</returns> |
| | | 37 | | public static async Task<Response<RecognizedFormCollection>> WaitForCompletionAsync(this Task<RecognizeCustomFor |
| | | 38 | | { |
| | 0 | 39 | | var o = await operation.ConfigureAwait(false); |
| | 0 | 40 | | return await o.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); |
| | 0 | 41 | | } |
| | | 42 | | |
| | | 43 | | /// <summary> |
| | | 44 | | /// Periodically calls the server until the long-running operation completes. |
| | | 45 | | /// </summary> |
| | | 46 | | /// <param name="operation">The instance that this method was invoked on.</param> |
| | | 47 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | | 48 | | /// <returns>A <see cref="Response{T}"/> representing the result of the operation. It can be cast to a <see cref |
| | | 49 | | /// containing the recognized pages.</returns> |
| | | 50 | | public static async Task<Response<FormPageCollection>> WaitForCompletionAsync(this Task<RecognizeContentOperatio |
| | | 51 | | { |
| | 0 | 52 | | var o = await operation.ConfigureAwait(false); |
| | 0 | 53 | | return await o.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); |
| | 0 | 54 | | } |
| | | 55 | | |
| | | 56 | | /// <summary> |
| | | 57 | | /// Periodically calls the server until the long-running operation completes. |
| | | 58 | | /// </summary> |
| | | 59 | | /// <param name="operation">The instance that this method was invoked on.</param> |
| | | 60 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | | 61 | | /// <returns>A <see cref="Response{T}"/> representing the result of the operation. It can be cast to a <see cref |
| | | 62 | | /// containing meta-data about the trained model.</returns> |
| | | 63 | | public static async Task<Response<CustomFormModel>> WaitForCompletionAsync(this Task<TrainingOperation> operatio |
| | | 64 | | { |
| | 0 | 65 | | var o = await operation.ConfigureAwait(false); |
| | 0 | 66 | | return await o.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); |
| | 0 | 67 | | } |
| | | 68 | | |
| | | 69 | | /// <summary> |
| | | 70 | | /// Periodically calls the server until the long-running operation completes. |
| | | 71 | | /// </summary> |
| | | 72 | | /// <param name="operation">The instance that this method was invoked on.</param> |
| | | 73 | | /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> |
| | | 74 | | /// <returns>A <see cref="Response{T}"/> representing the result of the operation. It can be cast to a <see cref |
| | | 75 | | /// containing meta-data about the trained model.</returns> |
| | | 76 | | public static async Task<Response<CustomFormModelInfo>> WaitForCompletionAsync(this Task<CopyModelOperation> ope |
| | | 77 | | { |
| | 0 | 78 | | var o = await operation.ConfigureAwait(false); |
| | 0 | 79 | | return await o.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); |
| | 0 | 80 | | } |
| | | 81 | | } |
| | | 82 | | } |