internal static NetworkStatusResponse DeserializeNetworkStatusResponse(JsonElement element) { BlockIdentifier currentBlockIdentifier = default; long currentBlockTimestamp = default; BlockIdentifier genesisBlockIdentifier = default; Optional <BlockIdentifier> oldestBlockIdentifier = default; Optional <SyncStatus> syncStatus = default; IReadOnlyList <Peer> peers = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("current_block_identifier")) { currentBlockIdentifier = BlockIdentifier.DeserializeBlockIdentifier(property.Value); continue; } if (property.NameEquals("current_block_timestamp")) { currentBlockTimestamp = property.Value.GetInt64(); continue; } if (property.NameEquals("genesis_block_identifier")) { genesisBlockIdentifier = BlockIdentifier.DeserializeBlockIdentifier(property.Value); continue; } if (property.NameEquals("oldest_block_identifier")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } oldestBlockIdentifier = BlockIdentifier.DeserializeBlockIdentifier(property.Value); continue; } if (property.NameEquals("sync_status")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } syncStatus = SyncStatus.DeserializeSyncStatus(property.Value); continue; } if (property.NameEquals("peers")) { List <Peer> array = new List <Peer>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(Peer.DeserializePeer(item)); } peers = array; continue; } } return(new NetworkStatusResponse(currentBlockIdentifier, currentBlockTimestamp, genesisBlockIdentifier, oldestBlockIdentifier.Value, syncStatus.Value, peers)); }
internal NetworkStatusResponse(BlockIdentifier currentBlockIdentifier, long currentBlockTimestamp, BlockIdentifier genesisBlockIdentifier, BlockIdentifier oldestBlockIdentifier, SyncStatus syncStatus, IReadOnlyList <Peer> peers) { CurrentBlockIdentifier = currentBlockIdentifier; CurrentBlockTimestamp = currentBlockTimestamp; GenesisBlockIdentifier = genesisBlockIdentifier; OldestBlockIdentifier = oldestBlockIdentifier; SyncStatus = syncStatus; Peers = peers; }