Exemple #1
0
        internal static QueryMetricInterval DeserializeQueryMetricInterval(JsonElement element)
        {
            Optional <string>             intervalStartTime = default;
            Optional <QueryTimeGrainType> intervalType      = default;
            Optional <long> executionCount = default;
            Optional <IList <QueryMetricProperties> > metrics = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("intervalStartTime"))
                {
                    intervalStartTime = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("intervalType"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    intervalType = new QueryTimeGrainType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("executionCount"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    executionCount = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("metrics"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <QueryMetricProperties> array = new List <QueryMetricProperties>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(QueryMetricProperties.DeserializeQueryMetricProperties(item));
                    }
                    metrics = array;
                    continue;
                }
            }
            return(new QueryMetricInterval(intervalStartTime.Value, Optional.ToNullable(intervalType), Optional.ToNullable(executionCount), Optional.ToList(metrics)));
        }
        internal static TopQueries DeserializeTopQueries(JsonElement element)
        {
            Optional <int>                numberOfQueries                 = default;
            Optional <string>             aggregationFunction             = default;
            Optional <string>             observationMetric               = default;
            Optional <QueryTimeGrainType> intervalType                    = default;
            Optional <string>             startTime                       = default;
            Optional <string>             endTime                         = default;
            Optional <IReadOnlyList <QueryStatisticsProperties> > queries = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("numberOfQueries"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    numberOfQueries = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("aggregationFunction"))
                {
                    aggregationFunction = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("observationMetric"))
                {
                    observationMetric = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("intervalType"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    intervalType = new QueryTimeGrainType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("startTime"))
                {
                    startTime = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("endTime"))
                {
                    endTime = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("queries"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <QueryStatisticsProperties> array = new List <QueryStatisticsProperties>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(QueryStatisticsProperties.DeserializeQueryStatisticsProperties(item));
                    }
                    queries = array;
                    continue;
                }
            }
            return(new TopQueries(Optional.ToNullable(numberOfQueries), aggregationFunction.Value, observationMetric.Value, Optional.ToNullable(intervalType), startTime.Value, endTime.Value, Optional.ToList(queries)));
        }