internal OperationStatus(string id, Status?status, DateTimeOffset?startTime, DateTimeOffset?endTime, float?percentComplete, ErrorDetail error)
 {
     Id              = id;
     Status          = status;
     StartTime       = startTime;
     EndTime         = endTime;
     PercentComplete = percentComplete;
     Error           = error;
 }
        internal static ErrorResponse DeserializeErrorResponse(JsonElement element)
        {
            Optional <ErrorDetail> error = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("error"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    error = ErrorDetail.DeserializeErrorDetail(property.Value);
                    continue;
                }
            }
            return(new ErrorResponse(error.Value));
        }
Exemple #3
0
 internal ErrorResponse(ErrorDetail error)
 {
     Error = error;
 }
        internal static OperationStatus DeserializeOperationStatus(JsonElement element)
        {
            Optional <string>         id              = default;
            Optional <Status>         status          = default;
            Optional <DateTimeOffset> startTime       = default;
            Optional <DateTimeOffset> endTime         = default;
            Optional <float>          percentComplete = default;
            Optional <ErrorDetail>    error           = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("status"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    status = new Status(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("startTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    startTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("endTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    endTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("percentComplete"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    percentComplete = property.Value.GetSingle();
                    continue;
                }
                if (property.NameEquals("error"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("error"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            error = ErrorDetail.DeserializeErrorDetail(property0.Value);
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new OperationStatus(id.Value, Optional.ToNullable(status), Optional.ToNullable(startTime), Optional.ToNullable(endTime), Optional.ToNullable(percentComplete), error.Value));
        }