Beispiel #1
0
 internal JobExecution(string id, string name, string type, int?jobVersion, string stepName, int?stepId, Guid?jobExecutionId, JobExecutionLifecycle?lifecycle, ProvisioningState?provisioningState, DateTimeOffset?createTime, DateTimeOffset?startTime, DateTimeOffset?endTime, int?currentAttempts, DateTimeOffset?currentAttemptStartTime, string lastMessage, JobExecutionTarget target) : base(id, name, type)
 {
     JobVersion              = jobVersion;
     StepName                = stepName;
     StepId                  = stepId;
     JobExecutionId          = jobExecutionId;
     Lifecycle               = lifecycle;
     ProvisioningState       = provisioningState;
     CreateTime              = createTime;
     StartTime               = startTime;
     EndTime                 = endTime;
     CurrentAttempts         = currentAttempts;
     CurrentAttemptStartTime = currentAttemptStartTime;
     LastMessage             = lastMessage;
     Target                  = target;
 }
        internal static JobExecution DeserializeJobExecution(JsonElement element)
        {
            Optional <string> id                                  = default;
            Optional <string> name                                = default;
            Optional <string> type                                = default;
            Optional <int>    jobVersion                          = default;
            Optional <string> stepName                            = default;
            Optional <int>    stepId                              = default;
            Optional <Guid>   jobExecutionId                      = default;
            Optional <JobExecutionLifecycle> lifecycle            = default;
            Optional <ProvisioningState>     provisioningState    = default;
            Optional <DateTimeOffset>        createTime           = default;
            Optional <DateTimeOffset>        startTime            = default;
            Optional <DateTimeOffset>        endTime              = default;
            Optional <int>                currentAttempts         = default;
            Optional <DateTimeOffset>     currentAttemptStartTime = default;
            Optional <string>             lastMessage             = default;
            Optional <JobExecutionTarget> target                  = 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("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("jobVersion"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            jobVersion = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("stepName"))
                        {
                            stepName = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("stepId"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            stepId = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("jobExecutionId"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            jobExecutionId = property0.Value.GetGuid();
                            continue;
                        }
                        if (property0.NameEquals("lifecycle"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            lifecycle = new JobExecutionLifecycle(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("provisioningState"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            provisioningState = new ProvisioningState(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("createTime"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            createTime = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("startTime"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            startTime = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("endTime"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            endTime = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("currentAttempts"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            currentAttempts = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("currentAttemptStartTime"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            currentAttemptStartTime = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("lastMessage"))
                        {
                            lastMessage = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("target"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            target = JobExecutionTarget.DeserializeJobExecutionTarget(property0.Value);
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new JobExecution(id.Value, name.Value, type.Value, Optional.ToNullable(jobVersion), stepName.Value, Optional.ToNullable(stepId), Optional.ToNullable(jobExecutionId), Optional.ToNullable(lifecycle), Optional.ToNullable(provisioningState), Optional.ToNullable(createTime), Optional.ToNullable(startTime), Optional.ToNullable(endTime), Optional.ToNullable(currentAttempts), Optional.ToNullable(currentAttemptStartTime), lastMessage.Value, target.Value));
        }