Example #1
0
        internal static DiagnosticsInfo DeserializeDiagnosticsInfo(JsonElement element)
        {
            Optional <ModelState> modelState = default;
            Optional <IReadOnlyList <VariableState> > variableStates = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("modelState"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    modelState = ModelState.DeserializeModelState(property.Value);
                    continue;
                }
                if (property.NameEquals("variableStates"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <VariableState> array = new List <VariableState>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(VariableState.DeserializeVariableState(item));
                    }
                    variableStates = array;
                    continue;
                }
            }
            return(new DiagnosticsInfo(modelState.Value, Optional.ToList(variableStates)));
        }
Example #2
0
        internal static DetectionResultSummary DeserializeDetectionResultSummary(JsonElement element)
        {
            DetectionStatus status = default;
            Optional <IReadOnlyList <ErrorResponse> > errors         = default;
            Optional <IReadOnlyList <VariableState> > variableStates = default;
            DetectionRequest setupInfo = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("status"))
                {
                    status = property.Value.GetString().ToDetectionStatus();
                    continue;
                }
                if (property.NameEquals("errors"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <ErrorResponse> array = new List <ErrorResponse>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ErrorResponse.DeserializeErrorResponse(item));
                    }
                    errors = array;
                    continue;
                }
                if (property.NameEquals("variableStates"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <VariableState> array = new List <VariableState>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(VariableState.DeserializeVariableState(item));
                    }
                    variableStates = array;
                    continue;
                }
                if (property.NameEquals("setupInfo"))
                {
                    setupInfo = DetectionRequest.DeserializeDetectionRequest(property.Value);
                    continue;
                }
            }
            return(new DetectionResultSummary(status, Optional.ToList(errors), Optional.ToList(variableStates), setupInfo));
        }
        internal static LastDetectionResult DeserializeLastDetectionResult(JsonElement element)
        {
            Optional <IReadOnlyList <VariableState> > variableStates = default;
            Optional <IReadOnlyList <AnomalyState> >  results        = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("variableStates"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <VariableState> array = new List <VariableState>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(VariableState.DeserializeVariableState(item));
                    }
                    variableStates = array;
                    continue;
                }
                if (property.NameEquals("results"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <AnomalyState> array = new List <AnomalyState>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(AnomalyState.DeserializeAnomalyState(item));
                    }
                    results = array;
                    continue;
                }
            }
            return(new LastDetectionResult(Optional.ToList(variableStates), Optional.ToList(results)));
        }