예제 #1
0
 internal CloudTask(string id, string displayName, string url, string eTag, DateTimeOffset?lastModified, DateTimeOffset?creationTime, ExitConditions exitConditions, TaskState?state, DateTimeOffset?stateTransitionTime, TaskState?previousState, DateTimeOffset?previousStateTransitionTime, string commandLine, TaskContainerSettings containerSettings, IReadOnlyList <ResourceFile> resourceFiles, IReadOnlyList <OutputFile> outputFiles, IReadOnlyList <EnvironmentSetting> environmentSettings, AffinityInformation affinityInfo, TaskConstraints constraints, UserIdentity userIdentity, TaskExecutionInformation executionInfo, ComputeNodeInformation nodeInfo, MultiInstanceSettings multiInstanceSettings, TaskStatistics stats, TaskDependencies dependsOn, IReadOnlyList <ApplicationPackageReference> applicationPackageReferences, AuthenticationTokenSettings authenticationTokenSettings)
 {
     Id                           = id;
     DisplayName                  = displayName;
     Url                          = url;
     ETag                         = eTag;
     LastModified                 = lastModified;
     CreationTime                 = creationTime;
     ExitConditions               = exitConditions;
     State                        = state;
     StateTransitionTime          = stateTransitionTime;
     PreviousState                = previousState;
     PreviousStateTransitionTime  = previousStateTransitionTime;
     CommandLine                  = commandLine;
     ContainerSettings            = containerSettings;
     ResourceFiles                = resourceFiles;
     OutputFiles                  = outputFiles;
     EnvironmentSettings          = environmentSettings;
     AffinityInfo                 = affinityInfo;
     Constraints                  = constraints;
     UserIdentity                 = userIdentity;
     ExecutionInfo                = executionInfo;
     NodeInfo                     = nodeInfo;
     MultiInstanceSettings        = multiInstanceSettings;
     Stats                        = stats;
     DependsOn                    = dependsOn;
     ApplicationPackageReferences = applicationPackageReferences;
     AuthenticationTokenSettings  = authenticationTokenSettings;
 }
예제 #2
0
 internal SubtaskInformation(int?id, ComputeNodeInformation nodeInfo, DateTimeOffset?startTime, DateTimeOffset?endTime, int?exitCode, TaskContainerExecutionInformation containerInfo, TaskFailureInformation failureInfo, SubtaskState?state, DateTimeOffset?stateTransitionTime, SubtaskState?previousState, DateTimeOffset?previousStateTransitionTime, TaskExecutionResult?result)
 {
     Id                          = id;
     NodeInfo                    = nodeInfo;
     StartTime                   = startTime;
     EndTime                     = endTime;
     ExitCode                    = exitCode;
     ContainerInfo               = containerInfo;
     FailureInfo                 = failureInfo;
     State                       = state;
     StateTransitionTime         = stateTransitionTime;
     PreviousState               = previousState;
     PreviousStateTransitionTime = previousStateTransitionTime;
     Result                      = result;
 }
        internal static CloudTask DeserializeCloudTask(JsonElement element)
        {
            string                                      id                           = default;
            string                                      displayName                  = default;
            string                                      url                          = default;
            string                                      eTag                         = default;
            DateTimeOffset?                             lastModified                 = default;
            DateTimeOffset?                             creationTime                 = default;
            ExitConditions                              exitConditions               = default;
            TaskState?                                  state                        = default;
            DateTimeOffset?                             stateTransitionTime          = default;
            TaskState?                                  previousState                = default;
            DateTimeOffset?                             previousStateTransitionTime  = default;
            string                                      commandLine                  = default;
            TaskContainerSettings                       containerSettings            = default;
            IReadOnlyList <ResourceFile>                resourceFiles                = default;
            IReadOnlyList <OutputFile>                  outputFiles                  = default;
            IReadOnlyList <EnvironmentSetting>          environmentSettings          = default;
            AffinityInformation                         affinityInfo                 = default;
            TaskConstraints                             constraints                  = default;
            UserIdentity                                userIdentity                 = default;
            TaskExecutionInformation                    executionInfo                = default;
            ComputeNodeInformation                      nodeInfo                     = default;
            MultiInstanceSettings                       multiInstanceSettings        = default;
            TaskStatistics                              stats                        = default;
            TaskDependencies                            dependsOn                    = default;
            IReadOnlyList <ApplicationPackageReference> applicationPackageReferences = default;
            AuthenticationTokenSettings                 authenticationTokenSettings  = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("displayName"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    displayName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("url"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    url = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("eTag"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    eTag = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("lastModified"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    lastModified = property.Value.GetDateTimeOffset("S");
                    continue;
                }
                if (property.NameEquals("creationTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    creationTime = property.Value.GetDateTimeOffset("S");
                    continue;
                }
                if (property.NameEquals("exitConditions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    exitConditions = ExitConditions.DeserializeExitConditions(property.Value);
                    continue;
                }
                if (property.NameEquals("state"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    state = property.Value.GetString().ToTaskState();
                    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().ToTaskState();
                    continue;
                }
                if (property.NameEquals("previousStateTransitionTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    previousStateTransitionTime = property.Value.GetDateTimeOffset("S");
                    continue;
                }
                if (property.NameEquals("commandLine"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    commandLine = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("containerSettings"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    containerSettings = TaskContainerSettings.DeserializeTaskContainerSettings(property.Value);
                    continue;
                }
                if (property.NameEquals("resourceFiles"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <ResourceFile> array = new List <ResourceFile>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ResourceFile.DeserializeResourceFile(item));
                    }
                    resourceFiles = array;
                    continue;
                }
                if (property.NameEquals("outputFiles"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <OutputFile> array = new List <OutputFile>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(OutputFile.DeserializeOutputFile(item));
                    }
                    outputFiles = array;
                    continue;
                }
                if (property.NameEquals("environmentSettings"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <EnvironmentSetting> array = new List <EnvironmentSetting>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(EnvironmentSetting.DeserializeEnvironmentSetting(item));
                    }
                    environmentSettings = array;
                    continue;
                }
                if (property.NameEquals("affinityInfo"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    affinityInfo = AffinityInformation.DeserializeAffinityInformation(property.Value);
                    continue;
                }
                if (property.NameEquals("constraints"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    constraints = TaskConstraints.DeserializeTaskConstraints(property.Value);
                    continue;
                }
                if (property.NameEquals("userIdentity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    userIdentity = UserIdentity.DeserializeUserIdentity(property.Value);
                    continue;
                }
                if (property.NameEquals("executionInfo"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    executionInfo = TaskExecutionInformation.DeserializeTaskExecutionInformation(property.Value);
                    continue;
                }
                if (property.NameEquals("nodeInfo"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    nodeInfo = ComputeNodeInformation.DeserializeComputeNodeInformation(property.Value);
                    continue;
                }
                if (property.NameEquals("multiInstanceSettings"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    multiInstanceSettings = MultiInstanceSettings.DeserializeMultiInstanceSettings(property.Value);
                    continue;
                }
                if (property.NameEquals("stats"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    stats = TaskStatistics.DeserializeTaskStatistics(property.Value);
                    continue;
                }
                if (property.NameEquals("dependsOn"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    dependsOn = TaskDependencies.DeserializeTaskDependencies(property.Value);
                    continue;
                }
                if (property.NameEquals("applicationPackageReferences"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <ApplicationPackageReference> array = new List <ApplicationPackageReference>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ApplicationPackageReference.DeserializeApplicationPackageReference(item));
                    }
                    applicationPackageReferences = array;
                    continue;
                }
                if (property.NameEquals("authenticationTokenSettings"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    authenticationTokenSettings = AuthenticationTokenSettings.DeserializeAuthenticationTokenSettings(property.Value);
                    continue;
                }
            }
            return(new CloudTask(id, displayName, url, eTag, lastModified, creationTime, exitConditions, state, stateTransitionTime, previousState, previousStateTransitionTime, commandLine, containerSettings, resourceFiles, outputFiles, environmentSettings, affinityInfo, constraints, userIdentity, executionInfo, nodeInfo, multiInstanceSettings, stats, dependsOn, applicationPackageReferences, authenticationTokenSettings));
        }
        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));
        }