internal static ModuleIdentity DeserializeModuleIdentity(JsonElement element) { Optional <string> moduleId = default; Optional <string> managedBy = default; Optional <string> deviceId = default; Optional <string> generationId = default; Optional <string> etag = default; Optional <ModuleConnectionState> connectionState = default; Optional <DateTimeOffset> connectionStateUpdatedTime = default; Optional <DateTimeOffset> lastActivityTime = default; Optional <int> cloudToDeviceMessageCount = default; Optional <AuthenticationMechanism> authentication = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("moduleId")) { moduleId = property.Value.GetString(); continue; } if (property.NameEquals("managedBy")) { managedBy = property.Value.GetString(); continue; } if (property.NameEquals("deviceId")) { deviceId = property.Value.GetString(); continue; } if (property.NameEquals("generationId")) { generationId = property.Value.GetString(); continue; } if (property.NameEquals("etag")) { etag = property.Value.GetString(); continue; } if (property.NameEquals("connectionState")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } connectionState = new ModuleConnectionState(property.Value.GetString()); continue; } if (property.NameEquals("connectionStateUpdatedTime")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } connectionStateUpdatedTime = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("lastActivityTime")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } lastActivityTime = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("cloudToDeviceMessageCount")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } cloudToDeviceMessageCount = property.Value.GetInt32(); continue; } if (property.NameEquals("authentication")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } authentication = AuthenticationMechanism.DeserializeAuthenticationMechanism(property.Value); continue; } } return(new ModuleIdentity(moduleId.Value, managedBy.Value, deviceId.Value, generationId.Value, etag.Value, Optional.ToNullable(connectionState), Optional.ToNullable(connectionStateUpdatedTime), Optional.ToNullable(lastActivityTime), Optional.ToNullable(cloudToDeviceMessageCount), authentication.Value)); }
internal static ModuleIdentity DeserializeModuleIdentity(JsonElement element) { string moduleId = default; string managedBy = default; string deviceId = default; string generationId = default; string etag = default; ModuleConnectionState?connectionState = default; DateTimeOffset? connectionStateUpdatedTime = default; DateTimeOffset? lastActivityTime = default; int?cloudToDeviceMessageCount = default; AuthenticationMechanism authentication = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("moduleId")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } moduleId = property.Value.GetString(); continue; } if (property.NameEquals("managedBy")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } managedBy = property.Value.GetString(); continue; } if (property.NameEquals("deviceId")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } deviceId = property.Value.GetString(); continue; } if (property.NameEquals("generationId")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } generationId = property.Value.GetString(); continue; } if (property.NameEquals("etag")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } etag = property.Value.GetString(); continue; } if (property.NameEquals("connectionState")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } connectionState = new ModuleConnectionState(property.Value.GetString()); continue; } if (property.NameEquals("connectionStateUpdatedTime")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } connectionStateUpdatedTime = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("lastActivityTime")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } lastActivityTime = property.Value.GetDateTimeOffset("O"); continue; } if (property.NameEquals("cloudToDeviceMessageCount")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } cloudToDeviceMessageCount = property.Value.GetInt32(); continue; } if (property.NameEquals("authentication")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } authentication = AuthenticationMechanism.DeserializeAuthenticationMechanism(property.Value); continue; } } return(new ModuleIdentity(moduleId, managedBy, deviceId, generationId, etag, connectionState, connectionStateUpdatedTime, lastActivityTime, cloudToDeviceMessageCount, authentication)); }