本文整理汇总了C#中API.GetBalance方法的典型用法代码示例。如果您正苦于以下问题:C# API.GetBalance方法的具体用法?C# API.GetBalance怎么用?C# API.GetBalance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类API
的用法示例。
在下文中一共展示了API.GetBalance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: balanceButton_Click
private void balanceButton_Click(object sender, EventArgs e)
{
try
{
API api = new API(key.Text);
Clockwork.Balance result = api.GetBalance();
balance.Text = result.CurrencySymbol + result.Amount.ToString("#,0.00");
}
catch (APIException ex)
{
// You'll get an API exception for errors
// such as wrong key
MessageBox.Show("API Exception: " + ex.Message);
}
catch (WebException ex)
{
// Web exceptions mean you couldn't reach the mediaburst server
MessageBox.Show("Web Exception: " + ex.Message);
}
catch (ArgumentException ex)
{
// Argument exceptions are thrown for missing parameters,
// such as forgetting to set the username
MessageBox.Show("Argument Exception: " + ex.Message);
}
catch (Exception ex)
{
// Something else went wrong, the error message should help
MessageBox.Show("Unknown Exception: " + ex.Message);
}
}
示例2: GetBalance
public void GetBalance()
{
Clockwork.API api = new API(key);
Balance balance = api.GetBalance();
Assert.IsTrue( (balance.AccountType == AccountType.Invoice && balance.Amount <= 0) || (balance.AccountType == AccountType.PayAsYouGo && balance.Amount >= 0) );
}