internal static DeploymentDeviceState DeserializeDeploymentDeviceState(JsonElement element) { string deviceId = default; int retryCount = default; bool movedOnToNewDeployment = default; DeviceDeploymentState deviceState = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("deviceId")) { deviceId = property.Value.GetString(); continue; } if (property.NameEquals("retryCount")) { retryCount = property.Value.GetInt32(); continue; } if (property.NameEquals("movedOnToNewDeployment")) { movedOnToNewDeployment = property.Value.GetBoolean(); continue; } if (property.NameEquals("deviceState")) { deviceState = new DeviceDeploymentState(property.Value.GetString()); continue; } } return(new DeploymentDeviceState(deviceId, retryCount, movedOnToNewDeployment, deviceState)); }
internal DeploymentDeviceState(string deviceId, int retryCount, bool movedOnToNewDeployment, DeviceDeploymentState deviceState) { if (deviceId == null) { throw new ArgumentNullException(nameof(deviceId)); } DeviceId = deviceId; RetryCount = retryCount; MovedOnToNewDeployment = movedOnToNewDeployment; DeviceState = deviceState; }
internal static Device DeserializeDevice(JsonElement element) { string deviceId = default; string deviceClassId = default; string manufacturer = default; string model = default; Optional <string> groupId = default; Optional <UpdateId> lastAttemptedUpdateId = default; Optional <DeviceDeploymentState> deploymentStatus = default; Optional <UpdateId> installedUpdateId = default; bool onLatestUpdate = default; Optional <string> lastDeploymentId = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("deviceId")) { deviceId = property.Value.GetString(); continue; } if (property.NameEquals("deviceClassId")) { deviceClassId = property.Value.GetString(); continue; } if (property.NameEquals("manufacturer")) { manufacturer = property.Value.GetString(); continue; } if (property.NameEquals("model")) { model = property.Value.GetString(); continue; } if (property.NameEquals("groupId")) { groupId = property.Value.GetString(); continue; } if (property.NameEquals("lastAttemptedUpdateId")) { if (property.Value.ValueKind == JsonValueKind.Null) { lastAttemptedUpdateId = null; continue; } lastAttemptedUpdateId = UpdateId.DeserializeUpdateId(property.Value); continue; } if (property.NameEquals("deploymentStatus")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } deploymentStatus = new DeviceDeploymentState(property.Value.GetString()); continue; } if (property.NameEquals("installedUpdateId")) { if (property.Value.ValueKind == JsonValueKind.Null) { installedUpdateId = null; continue; } installedUpdateId = UpdateId.DeserializeUpdateId(property.Value); continue; } if (property.NameEquals("onLatestUpdate")) { onLatestUpdate = property.Value.GetBoolean(); continue; } if (property.NameEquals("lastDeploymentId")) { lastDeploymentId = property.Value.GetString(); continue; } } return(new Device(deviceId, deviceClassId, manufacturer, model, groupId.Value, lastAttemptedUpdateId.Value, Optional.ToNullable(deploymentStatus), installedUpdateId.Value, onLatestUpdate, lastDeploymentId.Value)); }
public static DeploymentDeviceState DeploymentDeviceState(string deviceId = null, int retryCount = default, bool movedOnToNewDeployment = default, DeviceDeploymentState deviceState = default) { return(new DeploymentDeviceState(deviceId, retryCount, movedOnToNewDeployment, deviceState)); }