Exemplo n.º 1
0
        internal static ErrorResponse DeserializeErrorResponse(JsonElement element)
        {
            GeneratedError error = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("error"))
                {
                    error = GeneratedError.DeserializeGeneratedError(property.Value);
                    continue;
                }
            }
            return(new ErrorResponse(error));
        }
        internal static InputError DeserializeInputError(JsonElement element)
        {
            string         id    = default;
            GeneratedError error = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("error"))
                {
                    error = GeneratedError.DeserializeGeneratedError(property.Value);
                    continue;
                }
            }
            return(new InputError(id, error));
        }
        internal static JobStateAutoGenerated DeserializeJobStateAutoGenerated(JsonElement element)
        {
            Optional <string>         displayName        = default;
            DateTimeOffset            createdDateTime    = default;
            Optional <DateTimeOffset> expirationDateTime = default;
            Guid           jobId = default;
            DateTimeOffset lastUpdateDateTime = default;
            JobState       status             = default;
            Optional <IReadOnlyList <GeneratedError> > errors = default;
            Optional <string> nextLink = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("displayName"))
                {
                    displayName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("createdDateTime"))
                {
                    createdDateTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("expirationDateTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    expirationDateTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("jobId"))
                {
                    jobId = property.Value.GetGuid();
                    continue;
                }
                if (property.NameEquals("lastUpdateDateTime"))
                {
                    lastUpdateDateTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("status"))
                {
                    status = property.Value.GetString().ToJobState();
                    continue;
                }
                if (property.NameEquals("errors"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <GeneratedError> array = new List <GeneratedError>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(GeneratedError.DeserializeGeneratedError(item));
                    }
                    errors = array;
                    continue;
                }
                if (property.NameEquals("nextLink"))
                {
                    nextLink = property.Value.GetString();
                    continue;
                }
            }
            return(new JobStateAutoGenerated(displayName.Value, createdDateTime, Optional.ToNullable(expirationDateTime), jobId, lastUpdateDateTime, status, Optional.ToList(errors), nextLink.Value));
        }