internal OperationStatus(string id, Status?status, DateTimeOffset?startTime, DateTimeOffset?endTime, float?percentComplete, ErrorResponseError error)
 {
     Id              = id;
     Status          = status;
     StartTime       = startTime;
     EndTime         = endTime;
     PercentComplete = percentComplete;
     Error           = error;
 }
 internal static ErrorResponse DeserializeErrorResponse(JsonElement element)
 {
     Optional<ErrorResponseError> error = default;
     foreach (var property in element.EnumerateObject())
     {
         if (property.NameEquals("error"))
         {
             error = ErrorResponseError.DeserializeErrorResponseError(property.Value);
             continue;
         }
     }
     return new ErrorResponse(error.Value);
 }
        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 <ErrorResponseError> error           = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("status"))
                {
                    status = new Status(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("startTime"))
                {
                    startTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("endTime"))
                {
                    endTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("percentComplete"))
                {
                    percentComplete = property.Value.GetSingle();
                    continue;
                }
                if (property.NameEquals("error"))
                {
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("error"))
                        {
                            error = ErrorResponseError.DeserializeErrorResponseError(property0.Value);
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new OperationStatus(id.Value, Optional.ToNullable(status), Optional.ToNullable(startTime), Optional.ToNullable(endTime), Optional.ToNullable(percentComplete), error.Value));
        }
예제 #4
0
        internal static ErrorResponse DeserializeErrorResponse(JsonElement element)
        {
            Optional <ErrorResponseError> error = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("error"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    error = ErrorResponseError.DeserializeErrorResponseError(property.Value);
                    continue;
                }
            }
            return(new ErrorResponse(error.Value));
        }