internal static JobPreparationTaskExecutionInformation DeserializeJobPreparationTaskExecutionInformation(JsonElement element)
        {
            DateTimeOffset          startTime = default;
            DateTimeOffset?         endTime   = default;
            JobPreparationTaskState state     = default;
            string taskRootDirectory          = default;
            string taskRootDirectoryUrl       = default;
            int?   exitCode = default;
            TaskContainerExecutionInformation containerInfo = default;
            TaskFailureInformation            failureInfo   = default;
            int                 retryCount    = default;
            DateTimeOffset?     lastRetryTime = default;
            TaskExecutionResult?result        = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("startTime"))
                {
                    startTime = property.Value.GetDateTimeOffset("S");
                    continue;
                }
                if (property.NameEquals("endTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    endTime = property.Value.GetDateTimeOffset("S");
                    continue;
                }
                if (property.NameEquals("state"))
                {
                    state = property.Value.GetString().ToJobPreparationTaskState();
                    continue;
                }
                if (property.NameEquals("taskRootDirectory"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    taskRootDirectory = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("taskRootDirectoryUrl"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    taskRootDirectoryUrl = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("exitCode"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    exitCode = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("containerInfo"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    containerInfo = TaskContainerExecutionInformation.DeserializeTaskContainerExecutionInformation(property.Value);
                    continue;
                }
                if (property.NameEquals("failureInfo"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    failureInfo = TaskFailureInformation.DeserializeTaskFailureInformation(property.Value);
                    continue;
                }
                if (property.NameEquals("retryCount"))
                {
                    retryCount = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("lastRetryTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    lastRetryTime = property.Value.GetDateTimeOffset("S");
                    continue;
                }
                if (property.NameEquals("result"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    result = property.Value.GetString().ToTaskExecutionResult();
                    continue;
                }
            }
            return(new JobPreparationTaskExecutionInformation(startTime, endTime, state, taskRootDirectory, taskRootDirectoryUrl, exitCode, containerInfo, failureInfo, retryCount, lastRetryTime, result));
        }
Ejemplo n.º 2
0
        internal static TaskExecutionInformation DeserializeTaskExecutionInformation(JsonElement element)
        {
            DateTimeOffset?startTime = default;
            DateTimeOffset?endTime   = default;
            int?           exitCode  = default;
            TaskContainerExecutionInformation containerInfo = default;
            TaskFailureInformation            failureInfo   = default;
            int                 retryCount      = default;
            DateTimeOffset?     lastRetryTime   = default;
            int                 requeueCount    = default;
            DateTimeOffset?     lastRequeueTime = default;
            TaskExecutionResult?result          = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("startTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    startTime = property.Value.GetDateTimeOffset("S");
                    continue;
                }
                if (property.NameEquals("endTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    endTime = property.Value.GetDateTimeOffset("S");
                    continue;
                }
                if (property.NameEquals("exitCode"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    exitCode = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("containerInfo"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    containerInfo = TaskContainerExecutionInformation.DeserializeTaskContainerExecutionInformation(property.Value);
                    continue;
                }
                if (property.NameEquals("failureInfo"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    failureInfo = TaskFailureInformation.DeserializeTaskFailureInformation(property.Value);
                    continue;
                }
                if (property.NameEquals("retryCount"))
                {
                    retryCount = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("lastRetryTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    lastRetryTime = property.Value.GetDateTimeOffset("S");
                    continue;
                }
                if (property.NameEquals("requeueCount"))
                {
                    requeueCount = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("lastRequeueTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    lastRequeueTime = property.Value.GetDateTimeOffset("S");
                    continue;
                }
                if (property.NameEquals("result"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    result = property.Value.GetString().ToTaskExecutionResult();
                    continue;
                }
            }
            return(new TaskExecutionInformation(startTime, endTime, exitCode, containerInfo, failureInfo, retryCount, lastRetryTime, requeueCount, lastRequeueTime, result));
        }
        internal static SubtaskInformation DeserializeSubtaskInformation(JsonElement element)
        {
            int?id = default;
            ComputeNodeInformation nodeInfo  = default;
            DateTimeOffset?        startTime = default;
            DateTimeOffset?        endTime   = default;
            int?exitCode = default;
            TaskContainerExecutionInformation containerInfo = default;
            TaskFailureInformation            failureInfo   = default;
            SubtaskState?       state = default;
            DateTimeOffset?     stateTransitionTime         = default;
            SubtaskState?       previousState               = default;
            DateTimeOffset?     previousStateTransitionTime = default;
            TaskExecutionResult?result = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    id = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("nodeInfo"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    nodeInfo = ComputeNodeInformation.DeserializeComputeNodeInformation(property.Value);
                    continue;
                }
                if (property.NameEquals("startTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    startTime = property.Value.GetDateTimeOffset("S");
                    continue;
                }
                if (property.NameEquals("endTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    endTime = property.Value.GetDateTimeOffset("S");
                    continue;
                }
                if (property.NameEquals("exitCode"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    exitCode = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("containerInfo"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    containerInfo = TaskContainerExecutionInformation.DeserializeTaskContainerExecutionInformation(property.Value);
                    continue;
                }
                if (property.NameEquals("failureInfo"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    failureInfo = TaskFailureInformation.DeserializeTaskFailureInformation(property.Value);
                    continue;
                }
                if (property.NameEquals("state"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    state = property.Value.GetString().ToSubtaskState();
                    continue;
                }
                if (property.NameEquals("stateTransitionTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    stateTransitionTime = property.Value.GetDateTimeOffset("S");
                    continue;
                }
                if (property.NameEquals("previousState"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    previousState = property.Value.GetString().ToSubtaskState();
                    continue;
                }
                if (property.NameEquals("previousStateTransitionTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    previousStateTransitionTime = property.Value.GetDateTimeOffset("S");
                    continue;
                }
                if (property.NameEquals("result"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    result = property.Value.GetString().ToTaskExecutionResult();
                    continue;
                }
            }
            return(new SubtaskInformation(id, nodeInfo, startTime, endTime, exitCode, containerInfo, failureInfo, state, stateTransitionTime, previousState, previousStateTransitionTime, result));
        }