internal static IndexingResult DeserializeIndexingResult(JsonElement element) { IndexingResult result = new IndexingResult(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("key")) { result.Key = property.Value.GetString(); continue; } if (property.NameEquals("errorMessage")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } result.ErrorMessage = property.Value.GetString(); continue; } if (property.NameEquals("status")) { result.Succeeded = property.Value.GetBoolean(); continue; } if (property.NameEquals("statusCode")) { result.Status = property.Value.GetInt32(); continue; } } return(result); }
internal static IndexDocumentsResult DeserializeIndexDocumentsResult(JsonElement element) { IReadOnlyList <IndexingResult> value = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value")) { List <IndexingResult> array = new List <IndexingResult>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(IndexingResult.DeserializeIndexingResult(item)); } } value = array; continue; } } return(new IndexDocumentsResult(value)); }
/// <summary> /// Initializes a new instance of the /// <see cref="IndexActionCompletedEventArgs{T}"/> class. /// </summary> /// <param name="sender"> /// The <see cref="SearchIndexingBufferedSender{T}"/> raising the event. /// </param> /// <param name="action"> /// The <see cref="IndexDocumentsAction{T}"/> that was completed. /// </param> /// <param name="result"> /// The <see cref="IndexingResult"/> of an action that was successfully /// completed. /// </param> /// <param name="isRunningSynchronously"> /// A value indicating whether the event handler was invoked /// synchronously or asynchronously. Please see /// <see cref="Azure.Core.SyncAsyncEventHandler{T}"/> for more details. /// </param> /// <param name="cancellationToken"> /// A cancellation token related to the original operation that raised /// the event. It's important for your handler to pass this token /// along to any asynchronous or long-running synchronous operations /// that take a token so cancellation will correctly propagate. The /// default value is <see cref="CancellationToken.None"/>. /// </param> /// <exception cref = "System.ArgumentNullException" > /// Thrown if <paramref name="sender"/>, <paramref name="action"/>, or /// <paramref name="result"/> are null. /// </exception> public IndexActionCompletedEventArgs( SearchIndexingBufferedSender <T> sender, IndexDocumentsAction <T> action, IndexingResult result, bool isRunningSynchronously, CancellationToken cancellationToken = default) : base(sender, action, isRunningSynchronously, cancellationToken) { Argument.AssertNotNull(result, nameof(result)); Result = result; }
/// <summary> /// Initializes a new instance of the /// <see cref="IndexActionCompletedEventArgs{T}"/> class. /// </summary> /// <param name="sender"> /// The <see cref="SearchIndexingBufferedSender{T}"/> raising the event. /// </param> /// <param name="action"> /// The <see cref="IndexDocumentsAction{T}"/> that failed. /// </param> /// <param name="result"> /// The <see cref="IndexingResult"/> of an action that failed to /// complete. /// </param> /// <param name="exception"> /// the <see cref="Exception"/> caused by an action that failed to /// complete. /// </param> /// <param name="isRunningSynchronously"> /// A value indicating whether the event handler was invoked /// synchronously or asynchronously. Please see /// <see cref="Azure.Core.SyncAsyncEventHandler{T}"/> for more details. /// </param> /// <param name="cancellationToken"> /// A cancellation token related to the original operation that raised /// the event. It's important for your handler to pass this token /// along to any asynchronous or long-running synchronous operations /// that take a token so cancellation will correctly propagate. The /// default value is <see cref="CancellationToken.None"/>. /// </param> /// <exception cref="System.ArgumentNullException"> /// Thrown if <paramref name="sender"/> or <paramref name="action"/> /// are null. /// </exception> public IndexActionFailedEventArgs( SearchIndexingBufferedSender <T> sender, IndexDocumentsAction <T> action, IndexingResult result, Exception exception, bool isRunningSynchronously, CancellationToken cancellationToken = default) : base(sender, action, isRunningSynchronously, cancellationToken) { // Do not validate - either might be null Result = result; Exception = exception; }
internal static IndexDocumentsResult DeserializeIndexDocumentsResult(JsonElement element) { IndexDocumentsResult result = new IndexDocumentsResult(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value")) { foreach (var item in property.Value.EnumerateArray()) { result.Results.Add(IndexingResult.DeserializeIndexingResult(item)); } continue; } } return(result); }