| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. See License.txt in the project root for |
| | 3 | | // license information. |
| | 4 | |
|
| | 5 | | using Microsoft.Azure.Search.Common; |
| | 6 | | using Microsoft.Azure.Search.Serialization; |
| | 7 | | using Newtonsoft.Json; |
| | 8 | |
|
| | 9 | | namespace Microsoft.Azure.Search.Models |
| | 10 | | { |
| | 11 | | /// <summary> |
| | 12 | | /// Encapsulates state required to continue fetching search results. This is necessary when Azure Cognitive Search c |
| | 13 | | /// fulfill a search request with a single response. |
| | 14 | | /// </summary> |
| | 15 | | /// <remarks> |
| | 16 | | /// This class supports using <c cref="JsonConvert">JsonConvert</c> to convert to and from a JSON payload. This can |
| | 17 | | /// call Azure Cognitive Search from a web application and you need to exchange continuation tokens with a browser o |
| | 18 | | /// through search results. |
| | 19 | | /// </remarks> |
| | 20 | | [JsonConverter(typeof(SearchContinuationTokenConverter))] |
| | 21 | | public class SearchContinuationToken |
| | 22 | | { |
| 76 | 23 | | internal SearchContinuationToken(string nextLink, SearchRequest nextPageParameters) |
| | 24 | | { |
| 76 | 25 | | Throw.IfArgumentNullOrEmpty(nextLink, nameof(nextLink)); |
| | 26 | |
|
| 76 | 27 | | NextLink = nextLink; |
| 76 | 28 | | NextPageParameters = nextPageParameters; // Will be null for GET responses. |
| 76 | 29 | | } |
| | 30 | |
|
| 44 | 31 | | internal string NextLink { get; } |
| | 32 | |
|
| 60 | 33 | | internal SearchRequest NextPageParameters { get; } |
| | 34 | |
|
| | 35 | | /// <summary> |
| | 36 | | /// Creates a new <c cref="SearchContinuationToken">SearchContinuationToken</c> for test purposes. |
| | 37 | | /// </summary> |
| | 38 | | /// <param name="nextLink">The @odata.nextLink of the continuation token.</param> |
| | 39 | | /// <returns>A new continuation token for test purposes only.</returns> |
| 18 | 40 | | public static SearchContinuationToken CreateTestToken(string nextLink) => CreateTestToken(nextLink, null, null); |
| | 41 | |
|
| | 42 | | /// <summary> |
| | 43 | | /// Creates a new <c cref="SearchContinuationToken">SearchContinuationToken</c> for test purposes. |
| | 44 | | /// </summary> |
| | 45 | | /// <param name="nextLink">The @odata.nextLink of the continuation token.</param> |
| | 46 | | /// <param name="searchText">Optional; The search text of the request represented by this token.</param> |
| | 47 | | /// <param name="searchParameters">Optional; Search parameters of the request represented by this token.</param> |
| | 48 | | /// <returns>A new continuation token for test purposes only.</returns> |
| | 49 | | public static SearchContinuationToken CreateTestToken(string nextLink, string searchText, SearchParameters searc |
| 36 | 50 | | new SearchContinuationToken(nextLink, searchParameters?.ToRequest(searchText)); |
| | 51 | | } |
| | 52 | | } |