internal static TaskStatusApiModel DeserializeTaskStatusApiModel(XElement element) { bool? completed = default; string failReason = default; long? id = default; object info = default; DateTimeOffset? lastAttempt = default; DateTimeOffset? queueTime = default; TaskStatusApiModelStatus?status = default; TaskStatusApiModelType? type = default; string waitingTime = default; string workingTime = default; if (element.Element("completed") is XElement completedElement) { completed = (bool?)completedElement; } if (element.Element("failReason") is XElement failReasonElement) { failReason = (string)failReasonElement; } if (element.Element("id") is XElement idElement) { id = (long?)idElement; } if (element.Element("info") is XElement infoElement) { info = infoElement.GetObjectValue(null); } if (element.Element("lastAttempt") is XElement lastAttemptElement) { lastAttempt = lastAttemptElement.GetDateTimeOffsetValue("O"); } if (element.Element("queueTime") is XElement queueTimeElement) { queueTime = queueTimeElement.GetDateTimeOffsetValue("O"); } if (element.Element("status") is XElement statusElement) { status = new TaskStatusApiModelStatus(statusElement.Value); } if (element.Element("type") is XElement typeElement) { type = new TaskStatusApiModelType(typeElement.Value); } if (element.Element("waitingTime") is XElement waitingTimeElement) { waitingTime = (string)waitingTimeElement; } if (element.Element("workingTime") is XElement workingTimeElement) { workingTime = (string)workingTimeElement; } return(new TaskStatusApiModel(completed, failReason, id, info, lastAttempt, queueTime, status, type, waitingTime, workingTime)); }
internal static TaskStatusApiModel DeserializeTaskStatusApiModel(JsonElement element) { Optional <bool> completed = default; Optional <string> failReason = default; Optional <long> id = default; Optional <object> info = default; Optional <DateTimeOffset> lastAttempt = default; Optional <DateTimeOffset> queueTime = default; Optional <TaskStatusApiModelStatus> status = default; Optional <TaskStatusApiModelType> type = default; Optional <string> waitingTime = default; Optional <string> workingTime = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("completed")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } completed = property.Value.GetBoolean(); continue; } if (property.NameEquals("failReason")) { failReason = property.Value.GetString(); continue; } if (property.NameEquals("id")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } id = property.Value.GetInt64(); continue; } if (property.NameEquals("info")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } info = property.Value.GetObject(); continue; } if (property.NameEquals("lastAttempt")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } lastAttempt = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("queueTime")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } queueTime = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("status")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } status = new TaskStatusApiModelStatus(property.Value.GetString()); continue; } if (property.NameEquals("type")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } type = new TaskStatusApiModelType(property.Value.GetString()); continue; } if (property.NameEquals("waitingTime")) { waitingTime = property.Value.GetString(); continue; } if (property.NameEquals("workingTime")) { workingTime = property.Value.GetString(); continue; } } return(new TaskStatusApiModel(Optional.ToNullable(completed), failReason.Value, Optional.ToNullable(id), info.Value, Optional.ToNullable(lastAttempt), Optional.ToNullable(queueTime), Optional.ToNullable(status), Optional.ToNullable(type), waitingTime.Value, workingTime.Value)); }