private async void FetchAvailableTrustlines() { using (var httpClient = new HttpClient()) { var json = await httpClient.GetStringAsync("https://sigfol.io/api/assets"); JObject jobject = JObject.Parse(json); JArray anchors = (JArray)jobject.GetValue("_embedded").ToObject <JObject>().GetValue("records"); foreach (JObject anchor in anchors) { TrustlineCard trustlineCard = new TrustlineCard(); Trustline trustline = new Trustline(); trustlineCard.Trustline = trustline; string fullAsset = anchor.GetValue("asset").ToString(); string[] assetArray = fullAsset.Split('-'); trustline.AssetCode = assetArray[0]; trustline.IssuerAddress = assetArray[1]; _trustlineCards.Add(trustlineCard); } } }
private void AddTrustline(object sender, RoutedEventArgs e) { var account = new Account(this.AccountAddressBox.Text, this.AccountSecretBox.Text); var trustline = new Trustline() { Account = account.Address, Currency = this.AddTrustlineCurrency.Text, Limit = this.AddTrustlineLimit.Text, Counterparty = this.AddTrustlineCounterparty.Text }; var allowRippling = this.AddTrustlineAllowRippling.IsChecked ?? false; this.AddTrustlineButton.IsEnabled = false; this.AddTrustlineBox.SelectedObject = null; new Thread(() => { object result = null; Exception ex = null; try { result = account.AddTrustline(client, trustline, allowRippling); } catch (Exception exc) { ex = exc; } this.Dispatcher.Invoke((Action) delegate { this.AddTrustlineButton.IsEnabled = true; if (ex != null) { this.AddTrustlineBox.SelectedObject = ex; } else { this.AddTrustlineBox.SelectedObject = result; } }); }).Start(); }
private void AddTrustline(object sender, RoutedEventArgs e) { var account = new Account(this.AccountAddressBox.Text, this.AccountSecretBox.Text); var trustline = new Trustline() { Account = account.Address, Currency = this.AddTrustlineCurrency.Text, Limit = this.AddTrustlineLimit.Text, Counterparty = this.AddTrustlineCounterparty.Text }; var allowRippling = this.AddTrustlineAllowRippling.IsChecked ?? false; this.AddTrustlineButton.IsEnabled = false; this.AddTrustlineBox.SelectedObject = null; new Thread(() => { object result = null; Exception ex = null; try { result = account.AddTrustline(client, trustline, allowRippling); } catch (Exception exc) { ex = exc; } this.Dispatcher.Invoke((Action)delegate { this.AddTrustlineButton.IsEnabled = true; if (ex != null) { this.AddTrustlineBox.SelectedObject = ex; } else { this.AddTrustlineBox.SelectedObject = result; } }); }).Start(); }