コード例 #1
0
        internal static OperationStatus DeserializeOperationStatus(JsonElement element)
        {
            Optional <string>              id        = default;
            Optional <string>              name      = default;
            Optional <DateTimeOffset?>     startTime = default;
            Optional <DateTimeOffset?>     endTime   = default;
            Optional <string>              status    = default;
            Optional <ErrorResponseCommon> error     = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("startTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        startTime = null;
                        continue;
                    }
                    startTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("endTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        endTime = null;
                        continue;
                    }
                    endTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("status"))
                {
                    status = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("error"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        error = null;
                        continue;
                    }
                    error = ErrorResponseCommon.DeserializeErrorResponseCommon(property.Value);
                    continue;
                }
            }
            return(new OperationStatus(id.Value, name.Value, Optional.ToNullable(startTime), Optional.ToNullable(endTime), status.Value, error.Value));
        }
コード例 #2
0
 internal OperationStatus(string id, string name, DateTimeOffset?startOn, DateTimeOffset?endOn, string status, ErrorResponseCommon error)
 {
     Id      = id;
     Name    = name;
     StartOn = startOn;
     EndOn   = endOn;
     Status  = status;
     Error   = error;
 }