internal IndexerExecutionInfo(IndexerStatus status, IndexerExecutionResult lastResult, IReadOnlyList <IndexerExecutionResult> executionHistory, IndexerLimits limits)
 {
     Status           = status;
     LastResult       = lastResult;
     ExecutionHistory = executionHistory;
     Limits           = limits;
 }
        internal static IndexerExecutionInfo DeserializeIndexerExecutionInfo(JsonElement element)
        {
            IndexerStatus          status     = default;
            IndexerExecutionResult lastResult = default;
            IReadOnlyList <IndexerExecutionResult> executionHistory = default;
            IndexerLimits limits = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("status"))
                {
                    status = property.Value.GetString().ToIndexerStatus();
                    continue;
                }
                if (property.NameEquals("lastResult"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    lastResult = IndexerExecutionResult.DeserializeIndexerExecutionResult(property.Value);
                    continue;
                }
                if (property.NameEquals("executionHistory"))
                {
                    List <IndexerExecutionResult> array = new List <IndexerExecutionResult>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(IndexerExecutionResult.DeserializeIndexerExecutionResult(item));
                        }
                    }
                    executionHistory = array;
                    continue;
                }
                if (property.NameEquals("limits"))
                {
                    limits = IndexerLimits.DeserializeIndexerLimits(property.Value);
                    continue;
                }
            }
            return(new IndexerExecutionInfo(status, lastResult, executionHistory, limits));
        }
Example #3
0
        internal static IndexerExecutionInfo DeserializeIndexerExecutionInfo(JsonElement element)
        {
            IndexerExecutionInfo result = new IndexerExecutionInfo();

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("status"))
                {
                    result.Status = property.Value.GetString().ToIndexerStatus();
                    continue;
                }
                if (property.NameEquals("lastResult"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    result.LastResult = IndexerExecutionResult.DeserializeIndexerExecutionResult(property.Value);
                    continue;
                }
                if (property.NameEquals("executionHistory"))
                {
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        result.ExecutionHistory.Add(IndexerExecutionResult.DeserializeIndexerExecutionResult(item));
                    }
                    continue;
                }
                if (property.NameEquals("limits"))
                {
                    result.Limits = IndexerLimits.DeserializeIndexerLimits(property.Value);
                    continue;
                }
            }
            return(result);
        }
 public static SearchIndexerStatus SearchIndexerStatus(
     IndexerStatus status,
     IndexerExecutionResult lastResult,
     IReadOnlyList <IndexerExecutionResult> executionHistory,
     SearchIndexerLimits limits) =>
 new SearchIndexerStatus(status, lastResult, executionHistory, limits);
Example #5
0
        public static SearchIndexerStatus SearchIndexerStatus(IndexerStatus status = default, IndexerExecutionResult lastResult = null, IEnumerable <IndexerExecutionResult> executionHistory = null, SearchIndexerLimits limits = null)
        {
            executionHistory ??= new List <IndexerExecutionResult>();

            return(new SearchIndexerStatus(status, lastResult, executionHistory?.ToList(), limits));
        }
        internal static IndexerExecutionResult DeserializeIndexerExecutionResult(JsonElement element)
        {
            IndexerExecutionResult result = new IndexerExecutionResult();

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("status"))
                {
                    result.Status = property.Value.GetString().ToIndexerExecutionStatus();
                    continue;
                }
                if (property.NameEquals("errorMessage"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    result.ErrorMessage = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("startTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    result.StartTime = property.Value.GetDateTimeOffset("S");
                    continue;
                }
                if (property.NameEquals("endTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    result.EndTime = property.Value.GetDateTimeOffset("S");
                    continue;
                }
                if (property.NameEquals("errors"))
                {
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        result.Errors.Add(ItemError.DeserializeItemError(item));
                    }
                    continue;
                }
                if (property.NameEquals("warnings"))
                {
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        result.Warnings.Add(ItemWarning.DeserializeItemWarning(item));
                    }
                    continue;
                }
                if (property.NameEquals("itemsProcessed"))
                {
                    result.ItemCount = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("itemsFailed"))
                {
                    result.FailedItemCount = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("initialTrackingState"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    result.InitialTrackingState = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("finalTrackingState"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    result.FinalTrackingState = property.Value.GetString();
                    continue;
                }
            }
            return(result);
        }