Beispiel #1
0
 internal JobResponse(string jobId, string queryCondition, DateTimeOffset?createdTime, DateTimeOffset?startTime, DateTimeOffset?endTime, long?maxExecutionTimeInSeconds, JobResponseType?type, CloudToDeviceMethodRequest cloudToDeviceMethod, TwinData updateTwin, JobResponseStatus?status, string failureReason, string statusMessage, DeviceJobStatistics deviceJobStatistics)
 {
     JobId                     = jobId;
     QueryCondition            = queryCondition;
     CreatedTime               = createdTime;
     StartTime                 = startTime;
     EndTime                   = endTime;
     MaxExecutionTimeInSeconds = maxExecutionTimeInSeconds;
     Type = type;
     CloudToDeviceMethod = cloudToDeviceMethod;
     UpdateTwin          = updateTwin;
     Status              = status;
     FailureReason       = failureReason;
     StatusMessage       = statusMessage;
     DeviceJobStatistics = deviceJobStatistics;
 }
        internal static JobResponse DeserializeJobResponse(JsonElement element)
        {
            Optional <string>                     jobId                     = default;
            Optional <string>                     queryCondition            = default;
            Optional <DateTimeOffset>             createdTime               = default;
            Optional <DateTimeOffset>             startTime                 = default;
            Optional <DateTimeOffset>             endTime                   = default;
            Optional <long>                       maxExecutionTimeInSeconds = default;
            Optional <JobResponseType>            type = default;
            Optional <CloudToDeviceMethodRequest> cloudToDeviceMethod = default;
            Optional <TwinData>                   updateTwin          = default;
            Optional <JobResponseStatus>          status              = default;
            Optional <string>                     failureReason       = default;
            Optional <string>                     statusMessage       = default;
            Optional <DeviceJobStatistics>        deviceJobStatistics = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("jobId"))
                {
                    jobId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("queryCondition"))
                {
                    queryCondition = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("createdTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    createdTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("startTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    startTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("endTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    endTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("maxExecutionTimeInSeconds"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    maxExecutionTimeInSeconds = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    type = new JobResponseType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("cloudToDeviceMethod"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    cloudToDeviceMethod = CloudToDeviceMethodRequest.DeserializeCloudToDeviceMethodRequest(property.Value);
                    continue;
                }
                if (property.NameEquals("updateTwin"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    updateTwin = TwinData.DeserializeTwinData(property.Value);
                    continue;
                }
                if (property.NameEquals("status"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    status = new JobResponseStatus(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("failureReason"))
                {
                    failureReason = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("statusMessage"))
                {
                    statusMessage = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("deviceJobStatistics"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    deviceJobStatistics = DeviceJobStatistics.DeserializeDeviceJobStatistics(property.Value);
                    continue;
                }
            }
            return(new JobResponse(jobId.Value, queryCondition.Value, Optional.ToNullable(createdTime), Optional.ToNullable(startTime), Optional.ToNullable(endTime), Optional.ToNullable(maxExecutionTimeInSeconds), Optional.ToNullable(type), cloudToDeviceMethod.Value, updateTwin.Value, Optional.ToNullable(status), failureReason.Value, statusMessage.Value, deviceJobStatistics.Value));
        }
 public static JobResponse JobResponse(string jobId = null, string queryCondition = null, DateTimeOffset?createdTime = null, DateTimeOffset?startTime = null, DateTimeOffset?endTime = null, long?maxExecutionTimeInSeconds = null, JobResponseType?type = null, CloudToDeviceMethodRequest cloudToDeviceMethod = null, TwinData updateTwin = null, JobResponseStatus?status = null, string failureReason = null, string statusMessage = null, DeviceJobStatistics deviceJobStatistics = null)
 {
     return(new JobResponse(jobId, queryCondition, createdTime, startTime, endTime, maxExecutionTimeInSeconds, type, cloudToDeviceMethod, updateTwin, status, failureReason, statusMessage, deviceJobStatistics));
 }